Title: test_ssl failure when fails to resolve
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.2, Python 3.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: pitrou, python-dev, r.david.murray
Priority: normal Keywords: buildbot, patch

Created on 2011-05-12 19:33 by r.david.murray, last changed 2012-12-28 18:05 by python-dev. This issue is now closed.

File name Uploaded Description Edit
ssl_connect_ex.patch pitrou, 2011-05-18 16:27 review
Messages (6)
msg135853 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-05-12 19:33

Antoine says that connect_ex should be returning an error, not None, in that situation.
msg135855 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-05-12 19:37
Judging by ssl.connect_ex's source code, this can only mean that socket.connect raised a socket error with a "None" errno...
msg135856 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-05-12 19:41
Which probably means it was a socket.timeout. When called on a non-SSL socket, connect_ex() returns 11 (EAGAIN) for timeout errors:

>>> s = socket.socket()
>>> s.settimeout(0.00001)
>>> s.connect_ex(("", 443))

But on SSL sockets, connect_ex() loses the errno (because it calls connect() on the underlying socket, not connect_ex(), and socket.timeout isn't raised with an errno):

>>> s = ssl.wrap_socket(socket.socket())
>>> s.settimeout(0.00001)
>>> print(s.connect_ex(("", 443)))
msg136251 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-05-18 16:27
Here is a patch.
msg136254 - (view) Author: Roundup Robot (python-dev) Date: 2011-05-18 16:52
New changeset 019d8ccdf03b by Antoine Pitrou in branch '3.2':
Issue #12065: connect_ex() on an SSL socket now returns the original errno

New changeset 162ed9841f14 by Antoine Pitrou in branch 'default':
Issue #12065: connect_ex() on an SSL socket now returns the original errno
msg178408 - (view) Author: Roundup Robot (python-dev) Date: 2012-12-28 18:05
New changeset 3436769a7964 by Antoine Pitrou in branch '2.7':
Backport Python 3.2 fix for issue #12065, and add another test for SSLSocket.connect_ex().
Date User Action Args
2012-12-28 18:05:44python-devsetmessages: + msg178408
2011-05-18 16:53:36pitrousetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2011-05-18 16:52:35python-devsetnosy: + python-dev
messages: + msg136254
2011-05-18 16:27:18pitrousetfiles: + ssl_connect_ex.patch
keywords: + patch
messages: + msg136251

stage: needs patch -> patch review
2011-05-12 19:41:13pitrousetmessages: + msg135856
2011-05-12 19:37:10pitrousetmessages: + msg135855
2011-05-12 19:33:39pitrousetnosy: + pitrou

versions: + Python 3.3
2011-05-12 19:33:12r.david.murraycreate