Skip to content

Commit 4fe621e

Browse files
committed
msgpack: Add 1.0.0 version support
Since msgpack 1.0.0 was released Unpacker does not have strict_map_key param and it is True by default now. It makes the Connector fail with an error: `ValueError: int is not allowed for map key` To solve this issue the __init__ method of the Response object was refactored and the strict_map_key param is added for versions less than 1.0.0 Fixes #155
1 parent 4f79627 commit 4fe621e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: tarantool/response.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,19 @@ def __init__(self, conn, response):
5050
# created in the __new__().
5151
# super(Response, self).__init__()
5252

53+
kwargs = dict(use_list=True)
54+
if msgpack.version >= (1, 0, 0):
55+
# XXX: Explain why it is necessary.
56+
kwargs['strict_map_key'] = False
5357
if msgpack.version >= (0, 5, 2) and conn.encoding == 'utf-8':
5458
# Get rid of the following warning.
5559
# > PendingDeprecationWarning: encoding is deprecated,
5660
# > Use raw=False instead.
57-
unpacker = msgpack.Unpacker(use_list=True, raw=False)
61+
kwargs['raw'] = False
5862
elif conn.encoding is not None:
59-
unpacker = msgpack.Unpacker(use_list=True, encoding=conn.encoding)
60-
else:
61-
unpacker = msgpack.Unpacker(use_list=True)
63+
kwargs['encoding'] = conn.encoding
6264

65+
unpacker = msgpack.Unpacker(**kwargs)
6366
unpacker.feed(response)
6467
header = unpacker.unpack()
6568

0 commit comments

Comments
 (0)