summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorInada Naoki <songofacandy@gmail.com>2020-12-18 14:21:27 +0900
committerGitHub <noreply@github.com>2020-12-18 14:21:27 +0900
commit753b3706d80a7bc5a29147730804e867b97eee57 (patch)
tree6150edca595bdf419644aa53c5e72db2554dc6e4 /test
parent8029f95516dbfddf2fea61efb06dc08ded84aab7 (diff)
downloadmsgpack-python-753b3706d80a7bc5a29147730804e867b97eee57.tar.gz
Fix overflow in unpacking timestamp to datetime (#452)
Diffstat (limited to 'test')
-rw-r--r--test/test_timestamp.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_timestamp.py b/test/test_timestamp.py
index edc488a..6a29be7 100644
--- a/test/test_timestamp.py
+++ b/test/test_timestamp.py
@@ -129,3 +129,14 @@ def test_pack_datetime():
assert x
assert x[0] == dt
assert msgpack.unpackb(packed) is None
+
+
+@pytest.mark.skipif(sys.version_info[0] == 2, reason="datetime support is PY3+ only")
+def test_issue451():
+ # https://github.com/msgpack/msgpack-python/issues/451
+ dt = datetime.datetime(2100, 1, 1, 1, 1, tzinfo=_utc)
+ packed = msgpack.packb(dt, datetime=True)
+ assert packed == b"\xd6\xff\xf4\x86eL"
+
+ unpacked = msgpack.unpackb(packed, timestamp=3)
+ assert dt == unpacked