summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-04-22 12:19:46 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-04-22 12:19:46 (GMT)
commit7a1e09f60cf1d64f204eecf05c6581185e55fe8a (patch)
tree05e02a7348195043c52713edec488cd7602cec1e /Lib
parentdcb2403022520028a633143602359a30080ed257 (diff)
downloadcpython-7a1e09f60cf1d64f204eecf05c6581185e55fe8a.zip
cpython-7a1e09f60cf1d64f204eecf05c6581185e55fe8a.tar.gz
cpython-7a1e09f60cf1d64f204eecf05c6581185e55fe8a.tar.bz2
Merged revisions 80362 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80362 | senthil.kumaran | 2010-04-22 17:40:13 +0530 (Thu, 22 Apr 2010) | 4 lines Changed tests to only urlparse one, which was enough, addressed Ezio's comment on Invalid url check statement and versionchanged string in docs. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_urlparse.py4
-rw-r--r--Lib/urllib/parse.py14
2 files changed, 8 insertions, 10 deletions
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
index a0b2d77..f67487d 100644
--- a/Lib/test/test_urlparse.py
+++ b/Lib/test/test_urlparse.py
@@ -273,10 +273,10 @@ class UrlParseTestCase(unittest.TestCase):
for invalid_url in [
'http://::12.34.56.78]/',
'http://[::1/foo/',
+ 'ftp://[::1/foo/bad]/bad',
'http://[::1/foo/bad]/bad',
'http://[::ffff:12.34.56.78']:
- self.assertRaises(ValueError, lambda : urllib.parse.urlparse(invalid_url).hostname)
- self.assertRaises(ValueError, lambda : urllib.parse.urlparse(invalid_url))
+ self.assertRaises(ValueError, urllib.parse.urlparse, invalid_url)
def test_urldefrag(self):
for url, defrag, frag in [
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
index 4f48b25..3d541a7 100644
--- a/Lib/urllib/parse.py
+++ b/Lib/urllib/parse.py
@@ -181,10 +181,9 @@ def urlsplit(url, scheme='', allow_fragments=True):
url = url[i+1:]
if url[:2] == '//':
netloc, url = _splitnetloc(url, 2)
- if '[' in netloc :
- if not ']' in netloc: raise ValueError("Invalid IPv6 URL")
- if ']' in netloc:
- if not '[' in netloc: raise ValueError("Invalid IPv6 URL")
+ if (('[' in netloc and ']' not in netloc) or
+ (']' in netloc and '[' not in netloc)):
+ raise ValueError("Invalid IPv6 URL")
if allow_fragments and '#' in url:
url, fragment = url.split('#', 1)
if '?' in url:
@@ -199,10 +198,9 @@ def urlsplit(url, scheme='', allow_fragments=True):
scheme, url = url[:i].lower(), url[i+1:]
if url[:2] == '//':
netloc, url = _splitnetloc(url, 2)
- if '[' in netloc:
- if not ']' in netloc: raise ValueError("Invalid IPv6 URL")
- if ']' in netloc:
- if not '[' in netloc: raise ValueError("Invalid IPv6 URL")
+ if (('[' in netloc and ']' not in netloc) or
+ (']' in netloc and '[' not in netloc)):
+ raise ValueError("Invalid IPv6 URL")
if allow_fragments and scheme in uses_fragment and '#' in url:
url, fragment = url.split('#', 1)
if scheme in uses_query and '?' in url: