Skip to content

Eliminate deprecation warnings #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tarantool/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ def __init__(self, conn, response):
# created in the __new__().
# super(Response, self).__init__()

if conn.encoding is not None:
if msgpack.version >= (0, 5, 2) and conn.encoding == 'utf-8':
# Get rid of the following warning.
# > PendingDeprecationWarning: encoding is deprecated,
# > Use raw=False instead.
unpacker = msgpack.Unpacker(use_list=True, raw=False)
elif conn.encoding is not None:
unpacker = msgpack.Unpacker(use_list=True, encoding=conn.encoding)
else:
unpacker = msgpack.Unpacker(use_list=True)
Expand Down
7 changes: 4 additions & 3 deletions tarantool/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
import sys
import base64
import uuid

# Compatibility layer for Python2/Python3
Expand All @@ -12,6 +11,7 @@
binary_types = (str, )
else:
binary_types = (bytes, )
from base64 import decodestring as base64_decode

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

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