diff --git a/umsgpack.py b/umsgpack.py index 3094178..8ee5d77 100644 --- a/umsgpack.py +++ b/umsgpack.py @@ -19,10 +19,11 @@ def __init__(self, type, data): if not isinstance(type, int) or not (type >= 0 and type <= 127): raise TypeError("ext type out of range") # Check data is type bytes + elif (isinstance(sys.version_info, tuple) or + sys.version_info.major == 2) and not isinstance(data, str): + raise TypeError("ext data is not type \'str\'") elif sys.version_info.major == 3 and not isinstance(data, bytes): raise TypeError("ext data is not type \'bytes\'") - elif sys.version_info.major == 2 and not isinstance(data, str): - raise TypeError("ext data is not type \'str\'") self.type = type self.data = data @@ -449,7 +450,7 @@ def __init(): _float_size = 32 # Map packb and unpackb to the appropriate version - if sys.version_info.major == 3: + if not isinstance(sys.version_info, tuple) and sys.version_info.major == 3: packb = packb3 unpackb = unpackb3 else: