diff options
author | Skip Montanaro <skip@pobox.com> | 2002-03-24 16:53:50 +0000 |
---|---|---|
committer | Skip Montanaro <skip@pobox.com> | 2002-03-24 16:53:50 +0000 |
commit | 6f1855ff632928bcd52f8d250deb0aa124cf8c34 (patch) | |
tree | a20a458d4423153d92f187c6b4fe347868dfd99c /Lib/httplib.py | |
parent | a348402bcefb036354901a1a24daa05f874d9c34 (diff) | |
download | cpython-6f1855ff632928bcd52f8d250deb0aa124cf8c34.tar.gz |
add InvalidURL exception - raised if port is given but empty or non-numeric
Diffstat (limited to 'Lib/httplib.py')
-rw-r--r-- | Lib/httplib.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py index 4bad4638a4..ce819ebfbf 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -347,7 +347,10 @@ class HTTPConnection: if port is None: i = host.find(':') if i >= 0: - port = int(host[i+1:]) + try: + port = int(host[i+1:]) + except ValueError: + raise InvalidURL, "nonnumeric port: '%s'"%host[i+1:] host = host[:i] else: port = self.default_port @@ -808,6 +811,9 @@ class HTTPException(Exception): class NotConnected(HTTPException): pass +class InvalidURL(HTTPException): + pass + class UnknownProtocol(HTTPException): def __init__(self, version): self.version = version |