summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-05-19 14:16:22 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-05-19 14:16:22 (GMT)
commited1183db8b10c6955729824bf5f5bdc430878001 (patch)
treed29c8e4c8ffea3f83431ccec43a703c164123d7a /Lib
parentd527259f14dd6094f0a417ea83e66b8f233e38a3 (diff)
parent6709b7d5d1b8643856a3e0f864c0657a927f427a (diff)
downloadcpython-ed1183db8b10c6955729824bf5f5bdc430878001.zip
cpython-ed1183db8b10c6955729824bf5f5bdc430878001.tar.gz
cpython-ed1183db8b10c6955729824bf5f5bdc430878001.tar.bz2
#14072: merge with 3.2.
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/test/test_urlparse.py7
-rw-r--r--Lib/urllib/parse.py12
2 files changed, 13 insertions, 6 deletions
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
index 5784381..73150cf 100755
--- a/Lib/test/test_urlparse.py
+++ b/Lib/test/test_urlparse.py
@@ -806,6 +806,13 @@ class UrlParseTestCase(unittest.TestCase):
encoding='utf-8')
self.assertRaises(TypeError, urllib.parse.quote, b'foo', errors='strict')
+ def test_issue14072(self):
+ p1 = urllib.parse.urlsplit('tel:+31-641044153')
+ self.assertEqual(p1.scheme, 'tel')
+ self.assertEqual(p1.path, '+31-641044153')
+ p2 = urllib.parse.urlsplit('tel:+31641044153')
+ self.assertEqual(p2.scheme, 'tel')
+ self.assertEqual(p2.path, '+31641044153')
def test_main():
support.run_unittest(UrlParseTestCase)
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index 47b7962..92170ad 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -338,12 +338,12 @@ def urlsplit(url, scheme='', allow_fragments=True):
if c not in scheme_chars:
break
else:
- try:
- # make sure "url" is not actually a port number (in which case
- # "scheme" is really part of the path
- _testportnum = int(url[i+1:])
- except ValueError:
- scheme, url = url[:i].lower(), url[i+1:]
+ # make sure "url" is not actually a port number (in which case
+ # "scheme" is really part of the path)
+ rest = url[i+1:]
+ if not rest or any(c not in '0123456789' for c in rest):
+ # not a port number
+ scheme, url = url[:i].lower(), rest
if url[:2] == '//':
netloc, url = _splitnetloc(url, 2)