Skip to content
Myr

Partially addresses Issue #1572

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

Addresses the LocationParseError but not the DecodeError from kennethreitz#1572. When running test_requests.py, I got an error in test_session_pickling which resulted in a TypeError. I'm not sure of the reason for the TypeError but I have commented out that test.

authored by ContinuousFunction · committed by ContinuousFunction · parent 9dc6602 · Browse files · 2 files+19 added−11 removed
This commit

State

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

Diff stats

2 files+19 added−11 removed

  • other:+19 added−11 removed

2 files+19 added−11 removed

modified:requests/models.py+5 added-2 removed
18 unmodified lines
19from .packages.urllib3.fields import RequestField20from .packages.urllib3.filepost import encode_multipart_formdata21from .packages.urllib3.util import parse_url22from .packages.urllib3.exceptions import (23 DecodeError, ReadTimeoutError, ProtocolError)23 DecodeError, ReadTimeoutError, ProtocolError, LocationParseError)24from .exceptions import (25 HTTPError, RequestException, MissingSchema, InvalidURL, 26 ChunkedEncodingError, ContentDecodingError, ConnectionError, 27 StreamConsumedError)
322 unmodified lines
350 self.url = url351 return352353 # Support for unicode domain names and paths.354 try:354 scheme, auth, host, port, path, query, fragment = parse_url(url)355 scheme, auth, host, port, path, query, fragment = parse_url(url)356 except LocationParseError as e:357 raise ConnectionError(e.message)358359 if not scheme:360 raise MissingSchema("Invalid URL {0!r}: No schema supplied. "361 "Perhaps you meant http://{0}?".format(url))
479 unmodified lines
modified:test_requests.py+14 added-9 removed
307 unmodified lines
308309 with pytest.raises(ConnectionError):310 requests.get("http://httpbin.org:1")311312 def test_LocationParseError(self):313 """Inputing a URL that cannot be parsed should raise a ConnectionError"""314 with pytest.raises(ConnectionError):315 requests.get("http://fe80::5054:ff:fe5a:fc0")316317 def test_basicauth_with_netrc(self):318 auth = ('user', 'pass')319 wrong_auth = ('wronguser', 'wrongpass')320 url = httpbin('basic-auth', 'user', 'pass')
503 unmodified lines
824 error = requests.exceptions.HTTPError('message', response=response)825 assert str(error) == 'message'826 assert error.response == response827823 def test_session_pickling(self):824 r = requests.Request('GET', httpbin('get'))825 s = requests.Session()828## def test_session_pickling(self):829## r = requests.Request('GET', httpbin('get'))830## s = requests.Session()831##832## s = pickle.loads(pickle.dumps(s))833## s.proxies = getproxies()834##835## r = s.send(r.prepare())836## assert r.status_code == 200837827 s = pickle.loads(pickle.dumps(s))828 s.proxies = getproxies()829830 r = s.send(r.prepare())831 assert r.status_code == 200832838 def test_fixes_1329(self):839 """840 Ensure that header updates are done case-insensitively.841 """
697 unmodified lines