Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(868)

Unified Diff: Lib/urllib/parse.py

Issue 14843: support define_macros / undef_macros in setup.cfg
Patch Set: Created 11 months, 1 week ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/unittest/test/testmock/testmagicmethods.py ('k') | Lib/venv/__init__.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/urllib/parse.py Sat Jun 09 17:31:59 2012 +0100
+++ b/Lib/urllib/parse.py Mon May 21 23:01:17 2012 -0400
@@ -44,9 +44,16 @@
'imap', 'wais', 'file', 'mms', 'https', 'shttp',
'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '',
'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh']
+non_hierarchical = ['gopher', 'hdl', 'mailto', 'news',
+ 'telnet', 'wais', 'imap', 'snews', 'sip', 'sips']
uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap',
'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips',
'mms', '', 'sftp']
+uses_query = ['http', 'wais', 'imap', 'https', 'shttp', 'mms',
+ 'gopher', 'rtsp', 'rtspu', 'sip', 'sips', '']
+uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news',
+ 'nntp', 'wais', 'https', 'shttp', 'snews',
+ 'file', 'prospero', '']
# Characters valid in scheme names
scheme_chars = ('abcdefghijklmnopqrstuvwxyz'
@@ -143,9 +150,6 @@
port = self._hostinfo[1]
if port is not None:
port = int(port, 10)
- # Return None on an illegal port
- if not ( 0 <= port <= 65535):
- return None
return port
@@ -341,21 +345,21 @@
if c not in scheme_chars:
break
else:
- # 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
+ 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:]
if url[:2] == '//':
netloc, url = _splitnetloc(url, 2)
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:
+ if allow_fragments and scheme in uses_fragment and '#' in url:
url, fragment = url.split('#', 1)
- if '?' in url:
+ if scheme in uses_query and '?' in url:
url, query = url.split('?', 1)
v = SplitResult(scheme, netloc, url, query, fragment)
_parse_cache[key] = v
@@ -707,7 +711,7 @@
def quote_from_bytes(bs, safe='/'):
"""Like quote(), but accepts a bytes object rather than a str, and does
not perform string-to-bytes encoding. It always returns an ASCII string.
- quote_from_bytes(b'abc def\x3f') -> 'abc%20def%3f'
+ quote_from_bytes(b'abc def\xab') -> 'abc%20def%AB'
"""
if not isinstance(bs, (bytes, bytearray)):
raise TypeError("quote_from_bytes() expected bytes")
« no previous file with comments | « Lib/unittest/test/testmock/testmagicmethods.py ('k') | Lib/venv/__init__.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7