ssl.CertificateError not always available

This commit is contained in:
Matt Martz 2016-03-10 09:54:04 -06:00
parent 69bae532c5
commit e4218c7612
1 changed files with 7 additions and 2 deletions

View File

@ -205,8 +205,13 @@ else:
# Exception "constants" to support Python 2 through Python 3
try:
import ssl
HTTP_ERRORS = (HTTPError, URLError, socket.error, ssl.SSLError,
ssl.CertificateError)
try:
CERT_ERROR = (ssl.CertificateError,)
except AttributeError:
CERT_ERROR = tuple()
HTTP_ERRORS = ((HTTPError, URLError, socket.error, ssl.SSLError) +
CERT_ERROR)
except ImportError:
HTTP_ERRORS = (HTTPError, URLError, socket.error)