Closed paulo-raca closed 5 years ago
Thanks for the quick review :)
I should have spotted the unfortunate Python 2.7 vs Python 3.X inconsistencies this one introduced before the merge.
msg = i2c_msg.write(80, "ABC")
b = bytes(msg)[0] # In Python 2.7 bytes == str
isinstance(b, str) # True in Python 2.7
isinstance(b, int) # True in Python 3.x
A more important issue in Python 2.7, which there wasn't a unit test for, was that whenever are str(msg)
or any form of string generation of a msg
took place, __str__
would end up calling itself recursively. There is a fix on master now, but i won't release a new version just yet in case something more consistent comes up. Any ideas, @paulo-raca ?
Sorry, I completely ignored python 2.x 😅
Your fix seems good 👍
because
bytes(msg)
is easier and more efficient thanbytes(list(msg))
And, while we are at it, add
__str__
/__repr__
/__len__