Index: Lib/urlparse.py =================================================================== --- Lib/urlparse.py (revision 63658) +++ Lib/urlparse.py (working copy) @@ -102,8 +114,9 @@ class BaseResult(tuple): netloc = self.netloc if "@" in netloc: netloc = netloc.split("@", 1)[1] - if ":" in netloc: - netloc = netloc.split(":", 1)[0] + if netloc and netloc[-1] != ']' and ":" in netloc: + netloc = netloc.rsplit(":", 1)[0] + # FIXME: Remove the '[' ']' if RFC2732 IPv6 adress? return netloc.lower() or None @property @@ -111,8 +124,8 @@ class BaseResult(tuple): netloc = self.netloc if "@" in netloc: netloc = netloc.split("@", 1)[1] - if ":" in netloc: - port = netloc.split(":", 1)[1] + if netloc and netloc[-1] != ']' and ":" in netloc: + port = netloc.rsplit(":", 1)[1] return int(port, 10) return None