Skip to content

Commit e0232a4

Browse files
committed
Eliminate deprecation warnings
See [1] for more information about the msgpack warning. [1]: https://github.com/msgpack/msgpack-python/blob/381c2eff5f8ee0b8669fd6daf1fd1ecaffe7c931/README.rst#deprecating-encoding-option Fixes #114.
1 parent 137b336 commit e0232a4

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

tarantool/response.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ def __init__(self, conn, response):
4545
# created in the __new__().
4646
# super(Response, self).__init__()
4747

48-
if conn.encoding is not None:
48+
if msgpack.version >= (0, 5, 2) and conn.encoding == 'utf-8':
49+
# Get rid of the following warning.
50+
# > PendingDeprecationWarning: encoding is deprecated,
51+
# > Use raw=False instead.
52+
unpacker = msgpack.Unpacker(use_list=True, raw=False)
53+
elif conn.encoding is not None:
4954
unpacker = msgpack.Unpacker(use_list=True, encoding=conn.encoding)
5055
else:
5156
unpacker = msgpack.Unpacker(use_list=True)

tarantool/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22
import sys
3-
import base64
43
import uuid
54

65
# Compatibility layer for Python2/Python3
@@ -12,6 +11,7 @@
1211
binary_types = (str, )
1312
else:
1413
binary_types = (bytes, )
14+
from base64 import decodestring as base64_decode
1515

1616
def strxor(rhs, lhs):
1717
return "".join(chr(ord(x) ^ ord(y)) for x, y in zip(rhs, lhs))
@@ -21,6 +21,7 @@ def strxor(rhs, lhs):
2121
string_types = (str, )
2222
integer_types = (int, )
2323
ENCODING_DEFAULT = "utf-8"
24+
from base64 import decodebytes as base64_decode
2425

2526
def strxor(rhs, lhs):
2627
return bytes([x ^ y for x, y in zip(rhs, lhs)])
@@ -84,8 +85,8 @@ class Greeting:
8485
# Tarantool < 1.6.7 doesn't add "(Binary)" to greeting
8586
result.protocol = "Binary"
8687
elif len(tail.strip()) != 0:
87-
raise Exception("x") # Unsuported greeting
88-
result.salt = base64.decodestring(greeting_buf[64:])[:20]
88+
raise Exception("x") # Unsupported greeting
89+
result.salt = base64_decode(greeting_buf[64:])[:20]
8990
return result
9091
except Exception as e:
9192
print('exx', e)

0 commit comments

Comments
 (0)