attwad / python-osc

Open Sound Control server and client in pure python
The Unlicense
517 stars 108 forks source link

Compat with python2 is currently broken #10

Closed jchillerup closed 10 years ago

jchillerup commented 10 years ago

I can reproduce this ad lib in Python 2.7.6. It works fine in Python 3.

>>> from pythonosc import osc_message_builder, udp_client
>>> msg = osc_message_builder.OscMessageBuilder(address = "/foo")
>>> msg.add_arg("bar")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/pythonosc/osc_message_builder.py", line 69, in add_arg
    if builtin_type == builtins.str:
AttributeError: 'dict' object has no attribute 'str'

And if I try to specify the type directly it goes well at first, but breaks when you want to build the datagram.

>>> msg.add_arg("bar", msg.ARG_TYPE_STRING)
>>> msg.build()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/pythonosc/osc_message_builder.py", line 120, in build
    return osc_message.OscMessage(dgram)
  File "/usr/lib/python2.7/site-packages/pythonosc/osc_message.py", line 22, in __init__
    self._parse_datagram()
  File "/usr/lib/python2.7/site-packages/pythonosc/osc_message.py", line 56, in _parse_datagram
    raise ParseError('Found incorrect datagram, ignoring it', pe)
pythonosc.osc_message.ParseError: ('Found incorrect datagram, ignoring it', ParseError('Could not parse datagram string index out of range',))
attwad commented 10 years ago

Yes, as the description and the setup metadata on pypi of this project states, it is aimed at python 3, and all unit tests are done for python 3. I do not plan on adding python 2 support, feel free to fork this repo if you need it.