unpacker: fix silent datetime truncation with datetime=3 (#701)

This commit is contained in:
Inada Naoki 2026-06-19 20:48:27 +09:00 committed by GitHub
parent f1a170234a
commit d13418061d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View file

@ -176,3 +176,9 @@ def test_pack_datetime_without_tzinfo():
packed = msgpack.packb(dt, datetime=True)
unpacked = msgpack.unpackb(packed, timestamp=3)
assert unpacked == dt
def test_too_large_timestamp():
# When timestamp64 is too large, conversion to datetime fails due to int64 -> int32 conversion.
# https://github.com/msgpack/msgpack-python/issues/696
print(msgpack.unpackb(b"\xd7\xff" + b"\x00" * 8, timestamp=3))