JohnDoee / deluge-client

A very lightweight pure-python Deluge RPC Client
MIT License
87 stars 14 forks source link

Error when raising server errors in Python 3. #3

Closed elektito closed 7 years ago

elektito commented 8 years ago

In Python 3, when the server sends back an error and the client tries to raise an exception, this happens:

>>> from deluge_client import DelugeRPCClient
>>> c = DelugeRPCClient('10.0.3.3', 58846, 'wrong_username', 'wrong_password')
>>> c.connect()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mostafa/source/deluge-client/deluge_client/client.py", line 60, in connect
    result = self.call('daemon.login', self.username, self.password)
  File "/home/mostafa/source/deluge-client/deluge_client/client.py", line 102, in call
    exception = type(exception_type, (Exception, ), {})
TypeError: type() argument 1 must be str, not bytes

This is due to the fact that rencode.loads function returns a bytes object in Python 3 not an str while the type function expects a string.