Skip to content
Snippets Groups Projects
Commit 5bbbba61 authored by David Douard's avatar David Douard
Browse files

Drop support for legacy msgpack encodings in msgpack_loads

we should be free of them by now. The journal has been recreated from
scratch since then.
parent 68a35f8a
No related branches found
No related tags found
1 merge request!200Drop support for legacy msgpack encodings in msgpack_loads
......@@ -282,16 +282,6 @@ def msgpack_loads(data: bytes, extra_decoders=None) -> Any:
if decoder:
return decoder(obj[b"d"])
# Support for legacy encodings
if b"__datetime__" in obj and obj[b"__datetime__"]:
return iso8601.parse_date(obj[b"s"], default_timezone=None)
if b"__uuid__" in obj and obj[b"__uuid__"]:
return UUID(obj[b"s"])
if b"__timedelta__" in obj and obj[b"__timedelta__"]:
return datetime.timedelta(**obj[b"s"])
if b"__arrow__" in obj and obj[b"__arrow__"]:
return arrow.get(obj[b"s"])
# Fallthrough
return obj
......
......@@ -216,36 +216,6 @@ def test_serializers_decode_response_json(requests_mock):
assert decode_response(response) == DATA
def test_serializers_decode_legacy_msgpack():
legacy_msgpack = {
"bytes": b"\xc4\x0e123456789\x99\xaf\xff\x00\x12",
"datetime_tz": (
b"\x82\xc4\x0c__datetime__\xc3\xc4\x01s\xd9 "
b"2015-03-04T18:25:13.001234+01:58"
),
"datetime_utc": (
b"\x82\xc4\x0c__datetime__\xc3\xc4\x01s\xd9 "
b"2015-03-04T18:25:13.001234+00:00"
),
"datetime_delta": (
b"\x82\xc4\r__timedelta__\xc3\xc4\x01s\x83\xa4"
b"days@\xa7seconds\x00\xacmicroseconds\x00"
),
"arrow_date": (
b"\x82\xc4\t__arrow__\xc3\xc4\x01s\xd9 2018-04-25T16:17:53.533672+00:00"
),
"swhtype": b"\xa4fake",
"swh_dict": b"\x82\xa7swhtype*\xa1d\xa4test",
"random_dict": b"\x81\xa7swhtype+",
"uuid": (
b"\x82\xc4\x08__uuid__\xc3\xc4\x01s\xd9$"
b"cdd8f804-9db6-40c3-93ab-5955d3836234"
),
}
for k, v in legacy_msgpack.items():
assert msgpack_loads(v) == DATA[k]
def test_serializers_encode_native_datetime():
dt = datetime.datetime(2015, 1, 1, 12, 4, 42, 231455)
with pytest.raises(ValueError, match="naive datetime"):
......@@ -264,14 +234,6 @@ def test_serializers_decode_naive_datetime():
== expected_dt
)
# Legacy encoding
assert (
msgpack_loads(
b"\x82\xc4\x0c__datetime__\xc3\xc4\x01s\xba2015-01-01T12:04:42.231455"
)
== expected_dt
)
def test_msgpack_extra_encoders_mutation():
data = msgpack_dumps({}, extra_encoders=extra_encoders)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment