From: Serhiy Storchaka Date: Sat, 18 Jan 2014 16:31:41 +0000 (+0200) Subject: Issue #20270: urllib.urlparse now supports empty ports. X-Git-Tag: v3.4.0b3~103 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5d83d1a8141fa248356e4825857f166e4e65ec16;p=python Issue #20270: urllib.urlparse now supports empty ports. --- 5d83d1a8141fa248356e4825857f166e4e65ec16 diff --cc Lib/urllib/parse.py index 5328b9d329,975c6ffb9c..2ba39917cf --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@@ -898,10 -902,14 +898,13 @@@ def splitport(host) """splitport('host:port') --> 'host', 'port'.""" global _portprog if _portprog is None: - _portprog = re.compile('^(.*):([0-9]+)$') - import re + _portprog = re.compile('^(.*):([0-9]*)$') match = _portprog.match(host) - if match: return match.group(1, 2) + if match: + host, port = match.groups() + if port: + return host, port return host, None _nportprog = None