add InvalidURL exception - raised if port is given but empty or non-numeric

This commit is contained in:
Skip Montanaro 2002-03-24 16:53:50 +00:00
parent 1ce0073a4e
commit 9d38997e8c

View file

@ -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