diff --git a/CHANGES b/CHANGES index 6ef2c3b2b..e192bf5b7 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,8 @@ Features added Bugs fixed ---------- +* #3614: Sphinx crashes with requests-2.5.0 + Testing -------- diff --git a/sphinx/util/requests.py b/sphinx/util/requests.py index 48d9ae93a..9fe4cfdcd 100644 --- a/sphinx/util/requests.py +++ b/sphinx/util/requests.py @@ -36,6 +36,16 @@ except ImportError: # for requests < 2.4.0 InsecureRequestWarning = None +try: + from requests.packages.urllib3.exceptions import InsecurePlatformWarning +except ImportError: + try: + # for Debian-jessie + from urllib3.exceptions import InsecurePlatformWarning + except ImportError: + # for requests < 2.4.0 + InsecurePlatformWarning = None + # try to load requests[security] (but only if SSL is available) try: import ssl @@ -48,8 +58,8 @@ else: pkg_resources.VersionConflict): if not getattr(ssl, 'HAS_SNI', False): # don't complain on each url processed about the SSL issue - requests.packages.urllib3.disable_warnings( - requests.packages.urllib3.exceptions.InsecurePlatformWarning) + if InsecurePlatformWarning: + requests.packages.urllib3.disable_warnings(InsecurePlatformWarning) warnings.warn( 'Some links may return broken results due to being unable to ' 'check the Server Name Indication (SNI) in the returned SSL cert '