This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SSL timeouts should raise socket.timeout, not a generic SSLError
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: pitrou
Priority: normal Keywords:

Created on 2010-10-31 21:43 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg120090 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-31 21:43
The issue here is that ssl is using its own exception class rather than the socket module's "timeout" class:

test test_httplib failed -- Traceback (most recent call last):
  File "/Users/pythonbuildbot/buildarea/3.x.hansen-osx-x86-2/build/Lib/test/test_httplib.py", line 408, in test_networked
    h.request('GET', '/')
  File "/Users/pythonbuildbot/buildarea/3.x.hansen-osx-x86-2/build/Lib/http/client.py", line 943, in request
    self._send_request(method, url, body, headers)
  File "/Users/pythonbuildbot/buildarea/3.x.hansen-osx-x86-2/build/Lib/http/client.py", line 981, in _send_request
    self.endheaders(body)
  File "/Users/pythonbuildbot/buildarea/3.x.hansen-osx-x86-2/build/Lib/http/client.py", line 939, in endheaders
    self._send_output(message_body)
  File "/Users/pythonbuildbot/buildarea/3.x.hansen-osx-x86-2/build/Lib/http/client.py", line 791, in _send_output
    self.send(msg)
  File "/Users/pythonbuildbot/buildarea/3.x.hansen-osx-x86-2/build/Lib/http/client.py", line 737, in send
    self.connect()
  File "/Users/pythonbuildbot/buildarea/3.x.hansen-osx-x86-2/build/Lib/http/client.py", line 1086, in connect
    server_hostname=server_hostname)
  File "/Users/pythonbuildbot/buildarea/3.x.hansen-osx-x86-2/build/Lib/ssl.py", line 168, in wrap_socket
    _context=self)
  File "/Users/pythonbuildbot/buildarea/3.x.hansen-osx-x86-2/build/Lib/ssl.py", line 254, in __init__
    raise x
  File "/Users/pythonbuildbot/buildarea/3.x.hansen-osx-x86-2/build/Lib/ssl.py", line 250, in __init__
    self.do_handshake()
  File "/Users/pythonbuildbot/buildarea/3.x.hansen-osx-x86-2/build/Lib/ssl.py", line 429, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: _ssl.c:374: The handshake operation timed out
msg123287 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-12-03 19:57
Requalifying this issue so that the ssl module is fixed to raise socket.timeout on socket timeouts, which is not only more logical but much more useful (since you can then specifically handle this error).
msg123288 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-12-03 20:00
Committed in r86997. I won't backport it to bugfix branches since it is a small compatibility breach.
History
Date User Action Args
2022-04-11 14:57:08adminsetgithub: 54481
2010-12-03 20:00:10pitrousetstatus: open -> closed
resolution: fixed
messages: + msg123288

stage: resolved
2010-12-03 19:57:16pitrousetpriority: low -> normal

title: SSL handshake timeouts not caught by transient_internet -> SSL timeouts should raise socket.timeout, not a generic SSLError
messages: + msg123287
versions: - Python 3.1, Python 2.7
2010-10-31 21:43:51pitroucreate