Issue #28321: Fixed writing non-BMP characters with binary format in plistlib.
This commit is contained in:
commit
db8d6265fa
|
@ -918,7 +918,7 @@ class _BinaryPlistWriter (object):
|
||||||
self._write_size(0x50, len(value))
|
self._write_size(0x50, len(value))
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
t = value.encode('utf-16be')
|
t = value.encode('utf-16be')
|
||||||
self._write_size(0x60, len(value))
|
self._write_size(0x60, len(t) // 2)
|
||||||
|
|
||||||
self._fp.write(t)
|
self._fp.write(t)
|
||||||
|
|
||||||
|
|
|
@ -360,6 +360,13 @@ class TestPlistlib(unittest.TestCase):
|
||||||
plistlib.dumps,
|
plistlib.dumps,
|
||||||
testString)
|
testString)
|
||||||
|
|
||||||
|
def test_non_bmp_characters(self):
|
||||||
|
pl = {'python': '\U0001f40d'}
|
||||||
|
for fmt in ALL_FORMATS:
|
||||||
|
with self.subTest(fmt=fmt):
|
||||||
|
data = plistlib.dumps(pl, fmt=fmt)
|
||||||
|
self.assertEqual(plistlib.loads(data), pl)
|
||||||
|
|
||||||
def test_nondictroot(self):
|
def test_nondictroot(self):
|
||||||
for fmt in ALL_FORMATS:
|
for fmt in ALL_FORMATS:
|
||||||
with self.subTest(fmt=fmt):
|
with self.subTest(fmt=fmt):
|
||||||
|
|
|
@ -50,6 +50,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #28321: Fixed writing non-BMP characters with binary format in plistlib.
|
||||||
|
|
||||||
- Issue #28225: bz2 module now supports pathlib. Initial patch by Ethan Furman.
|
- Issue #28225: bz2 module now supports pathlib. Initial patch by Ethan Furman.
|
||||||
|
|
||||||
- Issue #28227: gzip now supports pathlib. Patch by Ethan Furman.
|
- Issue #28227: gzip now supports pathlib. Patch by Ethan Furman.
|
||||||
|
|
Loading…
Reference in New Issue