pklaus/brother_ql

incompatible 'bytes' types in pyusb.py and reader.py (python 2.x exception after printing)

madeinaus opened this issue · 0 comments

reader.py returns a response of type 'bytes'. backends\pyusb.py then coerces it to type 'bytes'. On python 3, this has no effect: it is a null operation. But on python 2, the two 'bytes' types are different, because they have been declared differently in the two files.

Unfortunately, the old 'bytes' type is not recognized by the new 'bytes' type, and reader.py gets

a bytes collection of the string character representation of the repr of the data, b'array ....
61 72 72 61 ...

rather than

a bytes collection of the data.


To make the two parts of the program match, in backends\pyusb.py, include the line

from builtins import bytes

or, modify the existing import of builtin str:
from builtins import str, bytes

As the documentation notes, use of python 2 does not prevent printing. This bug just creates a meaningless exception after the end of every printer operation, when bother_ql tries to analyze the response.