From 5d6eeb5a7f78a88e8808b62da4c62791ec00ec16 Mon Sep 17 00:00:00 2001 From: VasiliPupkin256 <27725951+VasiliPupkin256@users.noreply.github.com> Date: Sat, 13 Jan 2018 03:25:11 +0300 Subject: [PATCH 1/2] Map urllib3 ReadTimeoutError to an appropriate ReadTimeout requests exception, issue #2392 --- requests/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requests/models.py b/requests/models.py index 8eab3f64..e776bc34 100644 --- a/requests/models.py +++ b/requests/models.py @@ -33,7 +33,7 @@ from .cookies import cookiejar_from_dict, get_cookie_header, _copy_cookie_jar from .exceptions import ( HTTPError, MissingScheme, InvalidURL, ChunkedEncodingError, ContentDecodingError, ConnectionError, StreamConsumedError, - InvalidHeader, InvalidBodyError) + InvalidHeader, InvalidBodyError, ReadTimeout) from ._internal_utils import to_native_string, unicode_is_ascii from .utils import ( guess_filename, get_auth_from_url, requote_uri, @@ -742,7 +742,7 @@ class Response(object): except DecodeError as e: raise ContentDecodingError(e) except ReadTimeoutError as e: - raise ConnectionError(e) + raise ReadTimeout(e) else: # Standard file-like object. while True: From 8f00695d408c3dd924b39dbd3eddf0d1e1edf25f Mon Sep 17 00:00:00 2001 From: VasiliPupkin256 <27725951+VasiliPupkin256@users.noreply.github.com> Date: Sun, 14 Jan 2018 01:59:29 +0300 Subject: [PATCH 2/2] updating 3.0-HISTORY for #2392 --- 3.0-HISTORY.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/3.0-HISTORY.rst b/3.0-HISTORY.rst index 4c4c84df..a65aad1f 100644 --- a/3.0-HISTORY.rst +++ b/3.0-HISTORY.rst @@ -23,6 +23,10 @@ - Streaming responses with ``Response.iter_lines`` or ``Response.iter_content`` now requires an encoding to be set if one isn't provided by the server. + +- Exception raised during read timeout for ``Response.iter_content`` and + ``Response.iter_lines`` changed from ``ConnectionError`` to more + specific ``ReadTimeout``. - Raise exception if multiple locations are returned during a redirect.