diff options
| author | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-04 17:08:59 (GMT) |
|---|---|---|
| committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-04 17:08:59 (GMT) |
| commit | a854090c136473a6c1c46b0d7dddc52fdc168d07 (patch) | |
| tree | cff68bb15b9822c1a49398088ccb364b1e440760 | |
| parent | a6017786e9269cc1f13b5e0e62449693190968fa (diff) | |
| parent | db8d6265fa86a7cb9d7c5e4d60e3b342edc90176 (diff) | |
| download | cpython-a854090c136473a6c1c46b0d7dddc52fdc168d07.zip cpython-a854090c136473a6c1c46b0d7dddc52fdc168d07.tar.gz cpython-a854090c136473a6c1c46b0d7dddc52fdc168d07.tar.bz2 | |
Issue #28321: Fixed writing non-BMP characters with binary format in plistlib.
| -rw-r--r-- | Lib/plistlib.py | 2 | ||||
| -rw-r--r-- | Lib/test/test_plistlib.py | 7 | ||||
| -rw-r--r-- | Misc/NEWS | 2 |
3 files changed, 10 insertions, 1 deletions
diff --git a/Lib/plistlib.py b/Lib/plistlib.py index 4f360f3..09be5fd 100644 --- a/Lib/plistlib.py +++ b/Lib/plistlib.py @@ -918,7 +918,7 @@ class _BinaryPlistWriter (object): self._write_size(0x50, len(value)) except UnicodeEncodeError: t = value.encode('utf-16be') - self._write_size(0x60, len(value)) + self._write_size(0x60, len(t) // 2) self._fp.write(t) diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py index 60ff918..c77a6bf 100644 --- a/Lib/test/test_plistlib.py +++ b/Lib/test/test_plistlib.py @@ -360,6 +360,13 @@ class TestPlistlib(unittest.TestCase): plistlib.dumps, 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): for fmt in ALL_FORMATS: with self.subTest(fmt=fmt): @@ -58,6 +58,8 @@ Core and Builtins 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 #28227: gzip now supports pathlib. Patch by Ethan Furman. |
