mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Fix PyUnicode_FromFormatV("%c") for non-BMP char
Issue #10830: Fix PyUnicode_FromFormatV("%c") for non-BMP characters on narrow build.
This commit is contained in:
parent
ed4c71112a
commit
5ed8b2c737
3 changed files with 30 additions and 3 deletions
|
@ -1427,7 +1427,7 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
# Test PyUnicode_FromFormat()
|
||||
def test_from_format(self):
|
||||
support.import_module('ctypes')
|
||||
from ctypes import pythonapi, py_object
|
||||
from ctypes import pythonapi, py_object, c_int
|
||||
if sys.maxunicode == 65535:
|
||||
name = "PyUnicodeUCS2_FromFormat"
|
||||
else:
|
||||
|
@ -1452,6 +1452,9 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
'string, got a non-ASCII byte: 0xe9$',
|
||||
PyUnicode_FromFormat, b'unicode\xe9=%s', 'ascii')
|
||||
|
||||
self.assertEqual(PyUnicode_FromFormat(b'%c', c_int(0xabcd)), '\uabcd')
|
||||
self.assertEqual(PyUnicode_FromFormat(b'%c', c_int(0x10ffff)), '\U0010ffff')
|
||||
|
||||
# other tests
|
||||
text = PyUnicode_FromFormat(b'%%A:%A', 'abc\xe9\uabcd\U0010ffff')
|
||||
self.assertEqual(text, r"%A:'abc\xe9\uabcd\U0010ffff'")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue