Issue 28321: Plistlib: Half of the double width characters are missing when writing binary plist (original) (raw)
The simplest reproducer:
import plistlib plistlib.loads(plistlib.dumps('\U0001f40d', fmt=plistlib.FMT_BINARY)) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.5/plistlib.py", line 1006, in loads fp, fmt=fmt, use_builtin_types=use_builtin_types, dict_type=dict_type) File "/usr/lib/python3.5/plistlib.py", line 997, in load return p.parse(fp) File "/usr/lib/python3.5/plistlib.py", line 623, in parse return self._read_object(self._object_offsets[top_object]) File "/usr/lib/python3.5/plistlib.py", line 704, in _read_object return self._fp.read(s * 2).decode('utf-16be') File "/usr/lib/python3.5/encodings/utf_16_be.py", line 16, in decode return codecs.utf_16_be_decode(input, errors, True) UnicodeDecodeError: 'utf-16-be' codec can't decode bytes in position 0-1: unexpected end of data
Proposed patch fixes this issue.