Skip to content

Commit 7bfe503

Browse files
committed
add
1 parent 95ce60a commit 7bfe503

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

umsgpack.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ def __init__(self, type, data):
1919
if not isinstance(type, int) or not (type >= 0 and type <= 127):
2020
raise TypeError("ext type out of range")
2121
# Check data is type bytes
22+
elif (isinstance(sys.version_info, tuple) or
23+
sys.version_info.major == 2) and not isinstance(data, str):
24+
raise TypeError("ext data is not type \'str\'")
2225
elif sys.version_info.major == 3 and not isinstance(data, bytes):
2326
raise TypeError("ext data is not type \'bytes\'")
24-
elif sys.version_info.major == 2 and not isinstance(data, str):
25-
raise TypeError("ext data is not type \'str\'")
2627
self.type = type
2728
self.data = data
2829

@@ -449,7 +450,7 @@ def __init():
449450
_float_size = 32
450451

451452
# Map packb and unpackb to the appropriate version
452-
if sys.version_info.major == 3:
453+
if not isinstance(sys.version_info, tuple) and sys.version_info.major == 3:
453454
packb = packb3
454455
unpackb = unpackb3
455456
else:

0 commit comments

Comments
 (0)