From: Cory Benfield Date: Fri, 10 Aug 2012 16:29:12 +0000 (+0100) Subject: Throw InvalidURL not UnicodeError on bad label. X-Git-Tag: v0.13.7~8^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=79d53d3b8acf021203853e12e8fe0eeb0b742b51;p=services%2Fpython-requests.git Throw InvalidURL not UnicodeError on bad label. --- diff --git a/requests/models.py b/requests/models.py index 136427f..ae3c1be 100644 --- a/requests/models.py +++ b/requests/models.py @@ -413,7 +413,10 @@ class Request(object): if not scheme in SCHEMAS: raise InvalidSchema("Invalid scheme %r" % scheme) - netloc = netloc.encode('idna').decode('utf-8') + try: + netloc = netloc.encode('idna').decode('utf-8') + except UnicodeError: + raise InvalidURL('URL has an invalid label.') if not path: path = '/'