KBNLresearch / iromlab

Loader software for automated imaging of optical media with Nimbie disc robot
Apache License 2.0
31 stars 5 forks source link

Py3: AttributeError: 'str' object has no attribute 'decode' #23

Closed bitsgalore closed 7 years ago

bitsgalore commented 7 years ago

This happens when running under Py 3.6:

Exception in thread Thread-3:
Traceback (most recent call last):
  File "c:\python36\lib\threading.py", line 916, in _bo
    self.run()
  File "c:\python36\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "c:\python36\lib\site-packages\iromlab\cdworker.
r
    resultPrebatch = drivers.prebatch()
  File "c:\python36\lib\site-packages\iromlab\drivers.p
    logUTF8 = log.decode("utf-16le").encode("utf-8")
AttributeError: 'str' object has no attribute 'decode'

This happens b/c in Python 3 a str object is already decoded:

http://stackoverflow.com/a/28583969

So solution is to make decoding conditional on Py version.

bitsgalore commented 7 years ago

Fixed: https://github.com/KBNLresearch/iromlab/commit/24858a15ed0a17d8325b524d6be520e686848b71, works with Py 2.7 as well!