summaryrefslogtreecommitdiffstats
path: root/Lib/urlparse.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-01-18 16:30:09 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-01-18 16:30:09 (GMT)
commit326b5ab05a810dd75670b5e3386127d172bedca3 (patch)
treee4991c8dcd75130c1001b1944dea82392c1189ba /Lib/urlparse.py
parent7a278da4ee4ca2e4d98d8285c409dd1f370b46ce (diff)
downloadcpython-326b5ab05a810dd75670b5e3386127d172bedca3.zip
cpython-326b5ab05a810dd75670b5e3386127d172bedca3.tar.gz
cpython-326b5ab05a810dd75670b5e3386127d172bedca3.tar.bz2
Issue #20270: urllib and urlparse now support empty ports.
Diffstat (limited to 'Lib/urlparse.py')
-rw-r--r--Lib/urlparse.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/urlparse.py b/Lib/urlparse.py
index 4ce982e..4cd3d67 100644
--- a/Lib/urlparse.py
+++ b/Lib/urlparse.py
@@ -109,10 +109,11 @@ class ResultMixin(object):
netloc = self.netloc.split('@')[-1].split(']')[-1]
if ':' in netloc:
port = netloc.split(':')[1]
- port = int(port, 10)
- # verify legal port
- if (0 <= port <= 65535):
- return port
+ if port:
+ port = int(port, 10)
+ # verify legal port
+ if (0 <= port <= 65535):
+ return port
return None
from collections import namedtuple