From e4218c761203c0091e64efc9e3f82024d03f83b3 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Thu, 10 Mar 2016 09:54:04 -0600 Subject: [PATCH] ssl.CertificateError not always available --- speedtest.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/speedtest.py b/speedtest.py index c01942d..42f5c29 100755 --- a/speedtest.py +++ b/speedtest.py @@ -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)