summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2014-12-16 22:18:51 -0600
committerIan Cordasco <graffatcolmingov@gmail.com>2014-12-16 22:18:51 -0600
commit386c589ba0832eed62aef91a30adaed3d5648d1c (patch)
tree86c52a47a5fe7358749efe9de633e1b98ef4fd32
parentf723ab538f2cfa52ad25cdacb90d7d91fbdb3f00 (diff)
parent4c61fef13f53db220f95032b72e6e374970bf272 (diff)
downloadpython-requests-386c589ba0832eed62aef91a30adaed3d5648d1c.tar.gz
Merge branch 'master' of https://github.com/ContinuousFunction/requests into pr/2344
-rw-r--r--requests/models.py7
-rwxr-xr-xtest_requests.py5
2 files changed, 10 insertions, 2 deletions
diff --git a/requests/models.py b/requests/models.py
index 17ff4660..22b6d110 100644
--- a/requests/models.py
+++ b/requests/models.py
@@ -20,7 +20,7 @@ from .packages.urllib3.fields import RequestField
from .packages.urllib3.filepost import encode_multipart_formdata
from .packages.urllib3.util import parse_url
from .packages.urllib3.exceptions import (
- DecodeError, ReadTimeoutError, ProtocolError)
+ DecodeError, ReadTimeoutError, ProtocolError, LocationParseError)
from .exceptions import (
HTTPError, MissingSchema, InvalidURL, ChunkedEncodingError,
ContentDecodingError, ConnectionError, StreamConsumedError)
@@ -350,7 +350,10 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
return
# Support for unicode domain names and paths.
- scheme, auth, host, port, path, query, fragment = parse_url(url)
+ try:
+ scheme, auth, host, port, path, query, fragment = parse_url(url)
+ except LocationParseError as e:
+ raise InvalidURL(e.message)
if not scheme:
raise MissingSchema("Invalid URL {0!r}: No schema supplied. "
diff --git a/test_requests.py b/test_requests.py
index 68ee08c5..34348d3e 100755
--- a/test_requests.py
+++ b/test_requests.py
@@ -309,6 +309,11 @@ class RequestsTestCase(unittest.TestCase):
with pytest.raises(ConnectionError):
requests.get("http://httpbin.org:1")
+ def test_LocationParseError(self):
+ """Inputing a URL that cannot be parsed should raise an InvalidURL error"""
+ with pytest.raises(InvalidURL):
+ requests.get("http://fe80::5054:ff:fe5a:fc0")
+
def test_basicauth_with_netrc(self):
auth = ('user', 'pass')
wrong_auth = ('wronguser', 'wrongpass')