[stable-2.13] Guard urllib3 imports against all exceptions. Fixes #78648 (#78667) (#78672)

(cherry picked from commit f8e24e4)

Co-authored-by: Matt Martz <matt@sivel.net>
pull/78687/head
Matt Martz 3 years ago committed by GitHub
parent 9917b9f9f9
commit c51c5f97a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
bugfixes:
- urls - Guard imports of ``urllib3`` by catching ``Exception`` instead of
``ImportError`` to prevent exceptions in the import process of optional
dependencies from preventing use of ``urls.py``
(https://github.com/ansible/ansible/issues/78648)

@ -114,19 +114,19 @@ try:
HAS_URLLIB3_SSL_WRAP_SOCKET = False
try:
from urllib3.contrib.pyopenssl import PyOpenSSLContext
except ImportError:
except Exception:
from requests.packages.urllib3.contrib.pyopenssl import PyOpenSSLContext
HAS_URLLIB3_PYOPENSSLCONTEXT = True
except ImportError:
except Exception:
# urllib3<1.15,>=1.6
HAS_URLLIB3_PYOPENSSLCONTEXT = False
try:
try:
from urllib3.contrib.pyopenssl import ssl_wrap_socket
except ImportError:
except Exception:
from requests.packages.urllib3.contrib.pyopenssl import ssl_wrap_socket
HAS_URLLIB3_SSL_WRAP_SOCKET = True
except ImportError:
except Exception:
pass
# Select a protocol that includes all secure tls protocols

Loading…
Cancel
Save