8000 cleanup · loude/msgpack-python@bbdfd4d · GitHub
[go: up one dir, main page]

Skip to content

Commit bbdfd4d

Browse files
committed
cleanup
1 parent 93b5953 commit bbdfd4d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

msgpack/fallback.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
import struct
55
import warnings
66

7-
if sys.version_info[0] == 3:
8-
PY3 = True
7+
8+
if sys.version_info[0] == 2:
9+
PY2 = True
10+
int_types = (int, long)
11+
def dict_iteritems(d):
12+
return d.iteritems()
13+
else:
14+
PY2 = False
915
int_types = int
10-
Unicode = str
16+
unicode = str
1117
xrange = range
1218
def dict_iteritems(d):
1319
return d.items()
14-
else:
15-
PY3 = False
16-
int_types = (int, long)
17-
Unicode = unicode
18-
def dict_iteritems(d):
19-
return d.iteritems()
2020

2121
if sys.version_info < (3, 5):
2222
# Ugly hack...
@@ -97,7 +97,7 @@ def _get_data_from_buffer(obj):
9797
view = memoryview(obj)
9898
except TypeError:
9999
# try to use legacy buffer protocol if 2.7, otherwise re-raise
100-
if not PY3:
100+
if PY2:
101101
view = memoryview(buffer(obj))
102102
warnings.warn("using old buffer interface to unpack %s; "
103103
"this leads to unpacking errors if slicing is used and "
@@ -639,7 +639,7 @@ def _unpack(self, execute=EX_CONSTRUCT):
639639
ret = {}
640640
for _ in xrange(n):
641641
key = self._unpack(EX_CONSTRUCT)
642-
if self._strict_map_key and type(key) not in (Unicode, bytes):
642+
if self._strict_map_key and type(key) not in (unicode, bytes):
643643
raise ValueError("%s is not allowed for map key" % str(type(key)))
644644
ret[key] = self._unpack(EX_CONSTRUCT)
645645
if self._object_hook is not None:
@@ -819,7 +819,7 @@ def _pack(self, obj, nest_limit=DEFAULT_RECURSE_LIMIT,
819819
raise ValueError("%s is too large" % type(obj).__name__)
820820
self._pack_bin_header(n)
821821
return self._buffer.write(obj)
822-
if check(obj, Unicode):
822+
if check(obj, unicode):
823823
if self._encoding is None:
824824
raise TypeError(
825825
"Can't encode unicode string: "
@@ -1006,7 +1006,7 @@ def reset(self):
10061006

10071007
def getbuffer(self):
10081008
"""Return view of internal buffer."""
1009-
if USING_STRINGBUILDER or not PY3:
1009+
if USING_STRINGBUILDER or PY2:
10101010
return memoryview(self.bytes())
10111011
else:
10121012
return self._buffer.getbuffer()

0 commit comments

Comments
 (0)
0