summaryrefslogtreecommitdiffstats
path: root/Lib/urllib/parse.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/urllib/parse.py')
-rw-r--r--Lib/urllib/parse.py14
1 files changed, 6 insertions, 8 deletions
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: