mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Add C API PyUnicode_FromOrdinal() which exposes unichr() at C level.
u'%c' will now raise a ValueError in case the argument is an integer outside the valid range of Unicode code point ordinals. Closes SF bug #593581.
This commit is contained in:
parent
078151da90
commit
cc8764ca9d
5 changed files with 82 additions and 35 deletions
|
@ -453,6 +453,14 @@ except KeyError:
|
|||
else:
|
||||
verify(value == u'abc, def')
|
||||
|
||||
for ordinal in (-100, 0x20000):
|
||||
try:
|
||||
u"%c" % ordinal
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
print '*** formatting u"%%c" % %i should give a ValueError' % ordinal
|
||||
|
||||
# formatting jobs delegated from the string implementation:
|
||||
verify('...%(foo)s...' % {'foo':u"abc"} == u'...abc...')
|
||||
verify('...%(foo)s...' % {'foo':"abc"} == '...abc...')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue