mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Issue #14455: fix handling of unsigned long long values for binary plist files
Values in the range of an unsigned long long, but outside of the range of a signed long long were serialized as a negative value. Due to a bug in PyObjC my test scripts indicated that the previous behavior matched Apple's plist code, instead the handle large unsigned values correctly. The change to plistlib.py is from a patch by Serhiy.
This commit is contained in:
parent
3dcb0cf9b1
commit
94e44a935b
5 changed files with 79 additions and 78 deletions
|
@ -879,18 +879,19 @@ class _BinaryPlistWriter (object):
|
|||
try:
|
||||
self._fp.write(struct.pack('>Bq', 0x13, value))
|
||||
except struct.error:
|
||||
raise OverflowError(value)
|
||||
raise OverflowError(value) from None
|
||||
elif value < 1 << 8:
|
||||
self._fp.write(struct.pack('>BB', 0x10, value))
|
||||
elif value < 1 << 16:
|
||||
self._fp.write(struct.pack('>BH', 0x11, value))
|
||||
elif value < 1 << 32:
|
||||
self._fp.write(struct.pack('>BL', 0x12, value))
|
||||
elif value < 1 << 63:
|
||||
self._fp.write(struct.pack('>BQ', 0x13, value))
|
||||
elif value < 1 << 64:
|
||||
self._fp.write(b'\x14' + value.to_bytes(16, 'big', signed=True))
|
||||
else:
|
||||
try:
|
||||
self._fp.write(struct.pack('>BQ', 0x13, value))
|
||||
except struct.error:
|
||||
raise OverflowError(value)
|
||||
raise OverflowError(value)
|
||||
|
||||
elif isinstance(value, float):
|
||||
self._fp.write(struct.pack('>Bd', 0x23, value))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue