[New-bugs-announce] [issue17664] ssl.SSLError has errno value of None

Paul Wiseman report at bugs.python.org
Mon Apr 8 17:36:00 CEST 2013

New submission from Paul Wiseman:

I was using py2.7.3 and was getting None back for the errno attribute for an ssl.SSLError('The read operation timed out').

I noticed in the 2.7.4 release notes that it sounds like there was a fix for this:

Issue #12065: connect_ex() on an SSL socket now returns the original errno
when the socket's timeout expires (it used to return None).

I've just tested in py2.7.4 and I'm still getting None back for the errno attribute.

I'm using this code to produce the error:

import requests

def __init__(self, exception):
    # First extract the real underlying exception
    exception = exception.args[0]  # This should be ssl.SSLError
    super(requests.exceptions.ConnectionError, self).__init__(exception)
    self.strerror = exception.strerror
    self.errno = exception.errno

requests.exceptions.ConnectionError.__init__ = __init__

timeout_val = 0.2
while True:
        print requests.get("https://google.com", timeout=timeout_val)
    except requests.exceptions.SSLError as err:
        print err.strerror
        print err.errno
    except Exception as err:
        print "Got %s: %s" % (err.__class__.__name__, err)
    timeout_val /= 2

messages: 186310
nosy: Paul.Wiseman
priority: normal
severity: normal
status: open
title: ssl.SSLError has errno value of None
type: behavior
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list