Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 compatibility issue #34

Open
nltran opened this issue Aug 15, 2015 · 7 comments
Open

Python 3 compatibility issue #34

nltran opened this issue Aug 15, 2015 · 7 comments

Comments

@nltran
Copy link

nltran commented Aug 15, 2015

Although the changelog states that Python 3 is supported since 1.1.5, the following error occurs while running the following code in Python 3.4.3

from blinkstick import blinkstick

b = blinkstick.find_first()
b.set_random_color()
Traceback (most recent call last):
  File "C:/Users/Nam/PycharmProjects/yoloBlink/yolo.py", line 13, in <module>
    b.set_random_color()
  File "C:\Python34\lib\site-packages\blinkstick\blinkstick.py", line 600, in set_random_color
    self.set_color(name="random")
  File "C:\Python34\lib\site-packages\blinkstick\blinkstick.py", line 341, in set_color
    self._usb_ctrl_transfer(0x20, 0x9, report_id, 0, control_string)
  File "C:\Python34\lib\site-packages\blinkstick\blinkstick.py", line 226, in _usb_ctrl_transfer
    data = (c_ubyte * len(data_or_wLength))(*[c_ubyte(ord(c)) for c in data_or_wLength])
  File "C:\Python34\lib\site-packages\blinkstick\blinkstick.py", line 226, in <listcomp>
    data = (c_ubyte * len(data_or_wLength))(*[c_ubyte(ord(c)) for c in data_or_wLength])
TypeError: ord() expected string of length 1, but int found

Process finished with exit code 1

Removing the ord() call in line 226 of blinkstick.py fixes the error though.
data = (c_ubyte * len(data_or_wLength))(*[c_ubyte(c) for c in data_or_wLength])

I'm using blinkstick pro, Python 3.4.3 on windows 10. I installed blinkstick 1.1.7 with pip.

@DeveloperPaul123
Copy link

I'm also getting this same error on windows 8 running Python 3.4.3 and blinkstick 1.1.8

@atbradley
Copy link

I've fixed this on my fork and submitted a pull request.

@ortix
Copy link

ortix commented Oct 24, 2017

Can someone please merge this pull request?

@jacobm001
Copy link

Is this fix ever going to be implemented?

@petegibbins
Copy link

Just ran up against this myself - would appreciate it being merged in, thanks.

@lmame
Copy link

lmame commented Jul 10, 2018

I encountered the same problem, I used this to fix it:
data = (c_ubyte * len(data_or_wLength))(*[c_ubyte(ord(c) if type(c) is str else c) for c in data_or_wLength])

@UweZiegenhagen
Copy link

That helped me! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants