Skip to content
Myr

Merge pull request #774 from Lukasa/develop

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

Throw clear exceptions

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 27b55a7, 79d53d3 · Browse files · 2 files+9 added−1 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+9 added−1 removed

  • tests:+5 added−0 removed
  • other:+4 added−1 removed

2 files+9 added−1 removed

modified:requests/models.py+4 added-1 removed
411 unmodified lines
412413 if not scheme in SCHEMAS:414 raise InvalidSchema("Invalid scheme %r" % scheme)415416 try:416 netloc = netloc.encode('idna').decode('utf-8')417 netloc = netloc.encode('idna').decode('utf-8')418 except UnicodeError:419 raise InvalidURL('URL has an invalid label.')420421 if not path:422 path = '/'423
462 unmodified lines
modified:tests/test_requests.py+5 added
17 unmodified lines
18# import envoy19from requests import HTTPError20from requests import get, post, head, put21from requests.auth import HTTPBasicAuth, HTTPDigestAuth22from requests.exceptions import InvalidURL2324if 'HTTPBIN_URL' not in os.environ:25 os.environ['HTTPBIN_URL'] = 'http://httpbin.org/'26
1035 unmodified lines
1062 def test_bytes_files(self):1063 """Test that `bytes` can be used as the values of `files`."""1064 post(httpbin('post'), files={'test': b'test'})10651066 def test_invalid_urls_throw_requests_exception(self):1067 """Test that URLs with invalid labels throw1068 Requests.exceptions.InvalidURL instead of UnicodeError."""1069 self.assertRaises(InvalidURL, get, 'http://.google.com/')10701071if __name__ == '__main__':1072 unittest.main()