-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Labels
Description
Things to check first
-
I have searched the existing issues and didn't find my bug already reported there
-
I have checked that my bug is still present in the latest release
cbor2 version
5.6.5
Python version
3.13.1
What happened?
If I serialize with string_referencing= True
{"timestamp": datetime(2025,2,11), "a1": "abc", "a": "abc"}
and then deserialize then I get wrong result. Notice that 'a' have wrong value should be 'abc' but get '2025-02-11T00:00:00Z'
{'timestamp': datetime.datetime(2025, 2, 11, 0, 0, tzinfo=datetime.timezone.utc), 'a1': 'abc', 'a': '2025-02-11T00:00:00Z'}
How can we reproduce the bug?
import cbor2
from datetime import datetime, timezone
data = {"timestamp": datetime(2025,2,11), "a1": "abc", "a": "abc"}
des = cbor2.loads(cbor2.dumps(data, timezone=timezone.utc, string_referencing= True))
assert des == data, f"Deserialzied {des} is != to orginal data {data}"