Skip to content

Commit 8d340cc

Browse files
Revert "types: support working with binary for Python 3"
This reverts commit a2d79da.
1 parent a2d79da commit 8d340cc

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

tarantool/request.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
Request types definitions
55
'''
66

7-
import sys
87
import collections
98
import msgpack
109
import hashlib
@@ -85,13 +84,8 @@ def __init__(self, conn):
8584
# The option controls whether to pack binary (non-unicode)
8685
# string values as mp_bin or as mp_str.
8786
#
88-
# The default behaviour of the Python 2 connector is to pack
89-
# both bytes and Unicode strings as mp_str.
90-
#
91-
# The default behaviour of the Python 3 connector (since
92-
# default encoding is "utf-8") is to pack bytes as mp_bin
93-
# and Unicode strings as mp_str. encoding=None mode must
94-
# be used to work with non-utf strings.
87+
# The default behaviour of the connector is to pack both
88+
# bytes and Unicode strings as mp_str.
9589
#
9690
# msgpack-0.5.0 (and only this version) warns when the
9791
# option is unset:
@@ -104,10 +98,7 @@ def __init__(self, conn):
10498
# just always set it for all msgpack versions to get rid
10599
# of the warning on msgpack-0.5.0 and to keep our
106100
# behaviour on msgpack-1.0.0.
107-
if conn.encoding is None or sys.version_info.major == 2:
108-
packer_kwargs['use_bin_type'] = False
109-
else:
110-
packer_kwargs['use_bin_type'] = True
101+
packer_kwargs['use_bin_type'] = False
111102

112103
self.packer = msgpack.Packer(**packer_kwargs)
113104

tarantool/utils.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
if sys.version_info.major == 2:
77
string_types = (basestring, )
88
integer_types = (int, long)
9-
supported_types = integer_types + string_types + (float,)
10-
119
ENCODING_DEFAULT = None
12-
1310
if sys.version_info.minor < 6:
1411
binary_types = (str, )
1512
else:
@@ -20,13 +17,10 @@ def strxor(rhs, lhs):
2017
return "".join(chr(ord(x) ^ ord(y)) for x, y in zip(rhs, lhs))
2118

2219
elif sys.version_info.major == 3:
23-
binary_types = (bytes, )
24-
string_types = (str, )
25-
integer_types = (int, )
26-
supported_types = integer_types + string_types + binary_types + (float,)
27-
20+
binary_types = (bytes, )
21+
string_types = (str, )
22+
integer_types = (int, )
2823
ENCODING_DEFAULT = "utf-8"
29-
3024
from base64 import decodebytes as base64_decode
3125

3226
def strxor(rhs, lhs):
@@ -49,7 +43,7 @@ def check_key(*args, **kwargs):
4943
elif args[0] is None and kwargs['select']:
5044
return []
5145
for key in args:
52-
assert isinstance(key, supported_types)
46+
assert isinstance(key, integer_types + string_types + (float,))
5347
return list(args)
5448

5549

0 commit comments

Comments
 (0)