Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123967
D2695.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D2695.diff
View Options
diff --git a/swh/core/api/serializers.py b/swh/core/api/serializers.py
--- a/swh/core/api/serializers.py
+++ b/swh/core/api/serializers.py
@@ -208,8 +208,13 @@
return obj
try:
- return msgpack.unpackb(data, raw=False,
- object_hook=decode_types)
+ try:
+ return msgpack.unpackb(data, raw=False,
+ object_hook=decode_types,
+ strict_map_key=False)
+ except TypeError: # msgpack < 0.6.0
+ return msgpack.unpackb(data, raw=False,
+ object_hook=decode_types)
except TypeError: # msgpack < 0.5.2
return msgpack.unpackb(data, encoding='utf-8',
object_hook=decode_types)
diff --git a/swh/core/api/tests/test_serializers.py b/swh/core/api/tests/test_serializers.py
--- a/swh/core/api/tests/test_serializers.py
+++ b/swh/core/api/tests/test_serializers.py
@@ -106,8 +106,12 @@
self.assertEqual(self.encoded_data, json.loads(data))
def test_round_trip_msgpack(self):
- data = msgpack_dumps(self.data)
- self.assertEqual(self.data, msgpack_loads(data))
+ original_data = {
+ **self.data,
+ 'none_dict_key': {None: 42},
+ }
+ data = msgpack_dumps(original_data)
+ self.assertEqual(original_data, msgpack_loads(data))
def test_round_trip_msgpack_extra_types(self):
original_data = [ExtraType('baz', self.data), 'qux']
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 20 2024, 7:27 AM (11 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3218383
Attached To
D2695: Add support for non-str/bytes keys for msgpack >= 1.0.
Event Timeline
Log In to Comment