Closed tiewei closed 7 years ago
some e.g. proves the problem
-bash-4.2# python
Python 2.7.5 (default, Aug 29 2016, 10:12:21)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib3
>>> import requests
>>> urllib3.exceptions.HTTPError.__module__
'requests.packages.urllib3.exceptions'
>>> from urllib3.exceptions import HTTPError
>>> HTTPError.__module__
'urllib3.exceptions'
>>> urllib3.__version__
'1.10.2'
>>> requests.__version__
'2.6.0'
:+1: Looks good to me.
+1
👍 great catch!
urllib3.exceptions
module will be renamed asrequests.packages.urllib3.exceptions
whenpython-requests
is loaded, when tries to catchurllib3.exceptions
, it actually tries to catchrequests.packages.urllib3.exceptions
, at the same time urllib3 will always tries to throw exceptions with its own module name. As a result, no exceptions from urllib3 will be treated correctly (e.g. failed on reconnect). This commit imports urllib3 exception classes explicitly, so when tries to compare exception, it will always compares with the one from the same module.