SpotlightKid / micropython-osc

A minimal OSC client and server library for MicroPython.
MIT License
65 stars 10 forks source link

Error running client with Python 2.7 #1

Closed mrdooz closed 7 years ago

mrdooz commented 7 years ago

Running the client with Python 2.7.9 gives the following error:

    data.append(pack_blob(arg))
  File "c:\projects\c4d_osc\uosc\client.py", line 66, in pack_blob
    b = bytes(b, encoding)
TypeError: str() takes at most 1 argument (2 given)

I made a local fix by adding from builtins import bytes to the imports in client.py, but I haven't been able to do any rigorous testing, so I don't know if this will break something else..

SpotlightKid commented 7 years ago

Thanks for reporting this. This seems like a genuine bug. I'll look into fixing this asap.

SpotlightKid commented 7 years ago

Fixed in 4e3d3fe (along with quite a few other Python 2 incompatibilities in the client code).

Also fixed Python 2 incompatibilities in the server code in 64d5c68.

Seems my claims for Python 2 were a bit, umm, over-optimistic. However, all tests now pass for Python 3 and 2 and micropython. Test coverage absolutely isn't 100%, though, so if you stumble upon any other problems with Python 2, don't hesitate to open new issues.

One thing to note about Python 2 and OSC strings and blobs: when you use create_message and pass an argument of type str, it will be serialized as an OSC blob in Python 2. If you want an OSC string, either pass a unicode value, or use the tuple form ('s', 'foo').