summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2002-03-24 16:53:50 (GMT)
committerSkip Montanaro <skip@pobox.com>2002-03-24 16:53:50 (GMT)
commit9d38997e8c4d06ec5717276590a3f1c6a88d2bb7 (patch)
treee2b5fa565bc2fec4aa8af42cff52395c3bf36bc1 /Lib
parent1ce0073a4e1e5bbc3d710a6c4f1700db6b29827c (diff)
downloadcpython-9d38997e8c4d06ec5717276590a3f1c6a88d2bb7.zip
cpython-9d38997e8c4d06ec5717276590a3f1c6a88d2bb7.tar.gz
cpython-9d38997e8c4d06ec5717276590a3f1c6a88d2bb7.tar.bz2
add InvalidURL exception - raised if port is given but empty or non-numeric
Diffstat (limited to 'Lib')
-rw-r--r--Lib/httplib.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py
index 4bad463..ce819eb 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