Skip to content
Myr

handle urllib3 api changes; closes #2045

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Josh Schneier · committed by Josh Schneier · parent 3eb69be · Browse files · 3 files+5 added−19 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+5 added−19 removed

  • other:+5 added−19 removed

3 files+5 added−19 removed

modified:requests/compat.py-2 removed
90 unmodified lines
91 import cookielib92 from Cookie import Morsel93 from StringIO import StringIO94 from .packages.urllib3.packages.ordered_dict import OrderedDict95 from httplib import IncompleteRead9596 builtin_str = str97 bytes = str98 str = unicode
7 unmodified lines
106 from http import cookiejar as cookielib107 from http.cookies import Morsel108 from io import StringIO109 from collections import OrderedDict111 from http.client import IncompleteRead110111 builtin_str = str112 str = str113 bytes = bytes
2 unmodified lines
modified:requests/models.py+5 added-5 removed
7 unmodified lines
8"""910import collections11import datetime12import socket1213from io import BytesIO, UnsupportedOperation14from .hooks import default_hooks15from .structures import CaseInsensitiveDict
2 unmodified lines
18from .cookies import cookiejar_from_dict, get_cookie_header19from .packages.urllib3.fields import RequestField20from .packages.urllib3.filepost import encode_multipart_formdata21from .packages.urllib3.util import parse_url23from .packages.urllib3.exceptions import DecodeError22from .packages.urllib3.exceptions import (23 DecodeError, ReadTimeoutError, ProtocolError)24from .exceptions import (25 HTTPError, RequestException, MissingSchema, InvalidURL,26 ChunkedEncodingError, ContentDecodingError, ConnectionError)27from .utils import (
1 unmodified line
29 stream_decode_response_unicode, to_key_val_list, parse_header_links,30 iter_slices, guess_json_utf, super_len, to_native_string)31from .compat import (32 cookielib, urlunparse, urlsplit, urlencode, str, bytes, StringIO,33 is_py2, chardet, json, builtin_str, basestring, IncompleteRead)33 is_py2, chardet, json, builtin_str, basestring)34from .status_codes import codes3536#: The set of HTTP status codes that indicate an automatically37#: processable redirect.
598 unmodified lines
636 # Special case for urllib3.637 try:638 for chunk in self.raw.stream(chunk_size, decode_content=True):639 yield chunk640 except IncompleteRead as e:640 except ProtocolError as e:641 raise ChunkedEncodingError(e)642 except DecodeError as e:643 raise ContentDecodingError(e)644 except socket.error as e:644 except ReadTimeoutError as e:645 raise ConnectionError(e)646 except AttributeError:647 # Standard file-like object.648 while True:
168 unmodified lines
modified:test_requests.py-12 removed
718 unmodified lines
719 r.raw = io720 assert next(iter(r))721 io.close()722723 def test_iter_content_handles_socket_error(self):724 r = requests.Response()725 import socket726727 class RawMock(object):728 def stream(self, chunk_size, decode_content=None):729 raise socket.error()730731 r.raw = RawMock()732 with pytest.raises(ConnectionError):733 list(r.iter_content())734723 def test_response_decode_unicode(self):724 """725 When called with decode_unicode, Response.iter_content should always726 return unicode.
699 unmodified lines