Description
I've encountered a crash when using a Python2 router with a Python3 client.
Indeed, when the router send a autobahn.wamp.message.Error
containing kwargs the client crashes:
Traceback (most recent call last):
File "/home/emmanuel/projects/autobahn_sync/.tox/py34/lib/python3.4/site-packages/autobahn/wamp/websocket.py", line 90, in onMessage
self._session.onMessage(msg)
File "/home/emmanuel/projects/autobahn_sync/.tox/py34/lib/python3.4/site-packages/autobahn_sync/session.py", line 32, in onMessage
return super(_AsyncSession, self).onMessage(msg)
File "/home/emmanuel/projects/autobahn_sync/.tox/py34/lib/python3.4/site-packages/autobahn/wamp/protocol.py", line 921, in onMessage
txaio.reject(on_reply, self._exception_from_message(msg))
File "/home/emmanuel/projects/autobahn_sync/.tox/py34/lib/python3.4/site-packages/autobahn/wamp/protocol.py", line 248, in _exception_from_message
if msg.kwargs:
TypeError: __init__() keywords must be strings
The trouble is this kwargs's keys are made of bytes (i.e. python2's str
) but python3 wants unicode (python3's str
) to use them as function parameters
(Pdb) msg.kwargs
{b'message': 'event history for the given subscription is not available or enabled'}
The WAMP spec (https://tools.ietf.org/html/draft-oberstet-hybi-tavendo-wamp-02#section-5.2) only define the utf8-encoded string, I guess then everything should be in UTF-8.
Given there is no trouble when using Python3 everywhere, that mean the data's encoding depends of the sender which I believe is a bug both at serialization (should only send data in one encoding) and deserialization (should only accept data in one encoding) time.