Closed trashgordon-zz closed 10 years ago
This is an ugly fix, but it works for now:
def __init__(self, name, vendor="Unknown", model="Unknown",
dev_type="Unknown"):
if sys.version_info >= (3,0):
self.name = name
self.vendor = vendor
self.model = model
self.dev_type = dev_type
else:
self.name = name.decode('utf-8')
self.vendor = vendor.decode('utf-8')
self.model = model.decode('utf-8')
self.dev_type = dev_type.decode('utf-8')
self.__options = None # { "name" : ScannerOption }
IMHO, I think a safer bet would be to use if hasattr(string, 'decode').
Fixed by b1bb7e433210768f49f805a4d691e4b300ac6811
I'll do a new release with this change in one day or two
I agree, using hasattr() is much more elegant. Thanks for the fix!
v1.3.6 released with this fix. (sorry for the delay)
I am using Python 3.4.0 with the following code (I have not tested with other minor versions):
This works in Python 2.7.6. However, I get the following error in Python 3.4.0:
I believe the str.decode() method was dropped in Python 3, which is why the error is getting thrown due to this line in the Scanner constructor:
Since a string in Python 3 is already Unicode, perhaps there could just be a check on the parameters to see if they are already Unicode before attempting to decode them?