Republican US presidential candidate Donald Trump at a rally in Anaheim, California, on Wednesday. REUTERS/Jonathan Ernst

SHIMA, Japan — President Barack Obama asserted Tuesday that foreign leaders were "rattled" by Donald Trump and had good reason to feel that way, as he accused the presumptive Republican presidential nominee of ignorance about world affairs.

Weighing in on the Democratic race to replace him, Obama also downplayed concerns that the protracted fight between Hillary Clinton and Bernie Sanders was hurting his party's chances, brushing off their escalating attacks as the inevitable "grumpiness" of a primary campaign.

Obama's assessment of the presidential campaign came on the sidelines of a Group of Seven advanced economies summit in Japan, the latest world gathering to be colored by global concerns about Trump. Obama said foreign leaders at the conference were "surprised by the Republican nominee" and unsure how seriously to take his pronouncements.

"They are rattled by it — and for good reason," Obama said. "Because a lot of the proposals he has made display either ignorance of world affairs, or a cavalier attitude, or an interest in getting tweets and headlines."

He contrasted that to proposals that thoughtfully address what's required to keep the US safe and prosperous and "to keep the world on an even keel."

In a news conference, Obama brushed off calls for Sanders and Clinton to move hurriedly to resolve the primary so that Democrats can unite behind one candidate, arguing that unlike the Republicans, this year's Democratic candidates weren't that ideologically divided. He likened the hard-fought campaign between Clinton and Sanders to the one he waged with Clinton in 2008.

"During primaries, people get a little grumpy with each other," Obama said. "Somebody's supporter pops off and there's a certain buildup of aggravation. Every little speed bump, conflict trash-talking that takes place is elevated."

He urged both Democratic candidates to "try to stick to the issues," adding that the grumpiness often stemmed from voters' frustration when the campaign instead becomes dominated by talk about "personalities and character."