summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2019-07-05 16:27:00 -0700
committerSeth Michael Larson <sethmichaellarson@gmail.com>2019-07-05 18:27:00 -0500
commitc894210a893c1089169dc74bfec47da0121ed28e (patch)
treecb580ad5f6adea7812387fc2f40014fe31e139a8
parent582b3cbee60f2d9411c4adb9de8f2b1da7a5044a (diff)
downloadurllib3-c894210a893c1089169dc74bfec47da0121ed28e.tar.gz
Remove spurious TypeError from exception chain also for BaseException. (#1637)
-rw-r--r--CONTRIBUTORS.txt4
-rw-r--r--src/urllib3/connectionpool.py7
2 files changed, 8 insertions, 3 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 6f0362c3..0855f00a 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -278,5 +278,9 @@ In chronological order:
* James Meickle <https://permadeath.com/>
* Improve handling of Retry-After header
+* Chris Jerdonek <chris.jerdonek@gmail.com>
+ * Remove a spurious TypeError from the exception chain inside
+ HTTPConnectionPool._make_request(), also for BaseExceptions.
+
* [Your name or handle] <[email or website]>
* [Brief summary of your changes]
diff --git a/src/urllib3/connectionpool.py b/src/urllib3/connectionpool.py
index 77c31589..ee53c4b8 100644
--- a/src/urllib3/connectionpool.py
+++ b/src/urllib3/connectionpool.py
@@ -409,9 +409,10 @@ class HTTPConnectionPool(ConnectionPool, RequestMethods):
# Python 3
try:
httplib_response = conn.getresponse()
- except Exception as e:
- # Remove the TypeError from the exception chain in Python 3;
- # otherwise it looks like a programming error was the cause.
+ except BaseException as e:
+ # Remove the TypeError from the exception chain in
+ # Python 3 (including for exceptions like SystemExit).
+ # Otherwise it looks like a bug in the code.
six.raise_from(e, None)
except (SocketTimeout, BaseSSLError, SocketError) as e:
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)