tonysimpson / nanomsg-python

nanomsg wrapper for python with multiple backends (CPython and ctypes) should support 2/3 and Pypy
MIT License
382 stars 85 forks source link

Error on binding sockets in python 3.6 #61

Open DanielRoitenberg opened 6 years ago

DanielRoitenberg commented 6 years ago

Hi.

I have tried to run a code that binds a socket in python2.7 in python3.6: from nanomsg import REP, Socket, PAIR a = Socket(REP) a.bind("ipc://bla")

On python 2.7 the code works yet the output in python3.6 is: /usr/local/lib/python3.6/dist-packages/nanomsg_wrappers/__init__.py:22: UserWarning: Could not load the default wrapper for your platform: cpy, performance may be affected! "%s, performance may be affected!") % (default,)) Traceback (most recent call last): File "engine.py", line 5, in <module> a.bind("ipc://bla") File "/usr/local/lib/python3.6/dist-packages/nanomsg/__init__.py", line 273, in bind wrapper.nn_bind(self._fd, address) ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type

I stumbled an old issue : https://github.com/tonysimpson/nanomsg-python/issues/13 And according to it I changed the code to from nanomsg import REP, Socket, PAIR a = Socket(REP) a.bind("ipc://bla".encode())

It seems to fix it.