LIKE an indulgent parent forgiving of the most petulant of childish tantrums, China usually cuts North Korea a lot of slack. So when China on January 22nd signed on to United Nations Security Council Resolution 2087, tightening sanctions on North Korea to punish it for a rocket launch in December, its ally was surprised and outraged. Without naming China, a North Korean statement accused it of “abandoning without hesitation even elementary principles”. By the same token, the outside world saw an encouraging sign: perhaps China will at last take serious steps to rein in its pugnacious neighbour’s efforts to build a nuclear arsenal.

That is probably too much to hope. But on North Korea, China might for a while be more aligned than recently with America, Japan and South Korea. China has insisted that its main interest is in regional stability. If so, with North Korea reacting to the UN resolution by threatening to attack South Korea and stage its third test of a nuclear bomb and by vowing never to abandon its nuclear programme, it is hard not to see the country’s regime as a threat.

Moreover, Global Times, a Chinese newspaper owned by the Communist Party, chided North Korea for its ungrateful reaction to the efforts China had made to soften the UN resolution, and warned it that if it “engages in further nuclear tests, China will not hesitate to reduce its assistance”. Since North Korea relies on China for fuel and food, that is a potent threat.

Now, more than ever, China might want to seem a contributor to regional peace. Its belligerence over the disputed Senkaku or Diaoyu islands has brought relations with Japan to their worst level since 1945, with China now considering Japan’s proposal for a summit between its prime minister, Shinzo Abe, and the Communist Party leader, Xi Jinping. China’s assertion of territorial claims in the South China Sea has soured relations there, too. The Philippines has been provoked into asking a UN tribunal to rule on whether part of China’s claim has a legal basis.

On both those issues China will find it hard to offer concessions. This week Mr Xi growled that “no country should presume that we will engage in trade involving our core interests or that we will swallow the ‘bitter fruit’ of harming our sovereignty, security or development.”

North Korea offers a chance for China to seem flexible without jeopardising any “core interests” and, indeed, to enhance its own security at the same time. The new treatment of North Korea could also strengthen China’s relations with South Korea, which were damaged by the failure to join the widespread international condemnation of the North for attacks on the South in 2010. And it would offer what Zhu Feng, a scholar at Peking University, calls “a new platform for China and the United States to get closer”.

But Mr Zhu also says China will not want to “corner” North Korea. At a conference in Seoul in December, Teng Jianqun, of the China Institute of International Studies in Beijing, said there were three views about policy on North Korea: that it is a troublemaker which China should abandon and treat as a security problem; that it is nothing to do with China and should be left alone; and that it is an old ally deserving of China’s full support.

Yet the consensus is that China’s prime interest is stability. The survival of the Kim dynasty ruling North Korea now seems bound up with its nuclear programme. So China may think that stepping up efforts to shut that down would not be in its interest. Certainly many Chinese scholars and, presumably, officials feel exasperated with North Korea and rather embarrassed by its antics. But China fears that collapse of the regime might lead to unrest, refugees crossing into China and the presence of American forces on the other side of China’s own borders. That would be even worse.

Plenty of voices still call for the continued support of the regime. Mr Teng recalled that “old diplomats” complained fiercely when China condemned North Korea’s nuclear tests in 2006 and 2009. And Tang Ge, a commentator whose blogpost is translated on sinonk.com, a website, thunders against those who argue that North Korea no longer matters to China as a “strategic buffer” between it and the American troops in South Korea. On the contrary, he claims, supporting North Korea is a “small-cost big-benefit” activity.

This suggests another way of responding to China’s poor relationships with its other neighbours: to recall that North Korea is an old ally—and as “close as lips and teeth” with China. It is likely to remain so, even if, for now, the lips are pouting and the teeth are grinding.