SSLError has no attribute 'reason'
McSwindler opened this issue · comments
I ran across this error when the connection was timing out:
File "C:\Python27\lib\site-packages\deluge_client\client.py", line 52, in connect if e.reason != 'UNSUPPORTED_PROTOCOL' or not hasattr(ssl, 'PROTOCOL_SSLv3'): AttributeError: 'SSLError' object has no attribute 'reason'
added to line 52 a check for the reason attribute solves the surface issue.
if not hasattr(e, 'reason') or e.reason != 'UNSUPPORTED_PROTOCOL' or not hasattr(ssl, 'PROTOCOL_SSLv3'):
The underlying issue is my connection to deluge timing out, that's not something wrong with this project, but if you have any tips, I'm open ;) Perhaps adding an option for the user to set the timeout value.
File "C:\Python27\lib\site-packages\deluge_client\client.py", line 50, in connect self._socket.connect((self.host, self.port)) File "C:\Python27\lib\ssl.py", line 844, in connect self._real_connect(addr, False) File "C:\Python27\lib\ssl.py", line 835, in _real_connect self.do_handshake() File "C:\Python27\lib\ssl.py", line 808, in do_handshake self._sslobj.do_handshake() ssl.SSLError: ('_ssl.c:574: The handshake operation timed out',)
It is partly my fault, nothing in the project handles timeout properly. If you send an invalid command it'll also wait forever for a reply.
I'll see if I can make an easy fix that handles both command and connection timeout.
Hit the same thing:
>>> client.connect()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-a9f21c90fee7> in <module>()
----> 1 client.connect()
/usr/local/lib/python2.7/site-packages/deluge_client/client.pyc in connect(self)
50 self._socket.connect((self.host, self.port))
51 except ssl.SSLError as e:
---> 52 if e.reason != 'UNSUPPORTED_PROTOCOL' or not hasattr(ssl, 'PROTOCOL_SSLv3'):
53 raise
54
AttributeError: 'SSLError' object has no attribute 'reason'
Looks like SSLError.reason
was added in python 2.7.9, which would explain the AttributeError
being raised. Is there a consistent errno
property that could be used instead that corresponds to that reason?