Issue #3280: like chr() already does, the "%c" format now accepts the full unicode range

even on "narrow Unicode" builds; the result is a pair of UTF-16 surrogates.
This commit is contained in:
Amaury Forgeot d'Arc 2008-07-04 21:26:43 +00:00
parent 142957ce95
commit a4db68622c
4 changed files with 43 additions and 27 deletions

View file

@ -717,7 +717,10 @@ class UnicodeTest(
self.assertEqual("%(x)s, %(\xfc)s" % {'x':"abc", '\xfc':"def"}, 'abc, def')
self.assertEqual('%c' % 0x1234, '\u1234')
self.assertRaises(OverflowError, "%c".__mod__, (sys.maxunicode+1,))
self.assertEqual('%c' % 0x21483, '\U00021483')
self.assertRaises(OverflowError, "%c".__mod__, (0x110000,))
self.assertEqual('%c' % '\U00021483', '\U00021483')
self.assertRaises(TypeError, "%c".__mod__, "aa")
# formatting jobs delegated from the string implementation:
self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...')