cpython: a9d43e21f7d8 (original) (raw)
--- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -636,11 +636,20 @@ class UrlParseTestCase(unittest.TestCase ('s3', 'foo.com', '/stuff', '', '', '')) self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff"), ('x-newscheme', 'foo.com', '/stuff', '', '', ''))
self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff?query#fragment"),[](#l1.7)
('x-newscheme', 'foo.com', '/stuff', '', 'query', 'fragment'))[](#l1.8)
self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff?query"),[](#l1.9)
('x-newscheme', 'foo.com', '/stuff', '', 'query', ''))[](#l1.10)
+ # And for bytes... self.assertEqual(urllib.parse.urlparse(b"s3://foo.com/stuff"), (b's3', b'foo.com', b'/stuff', b'', b'', b'')) self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff"), (b'x-newscheme', b'foo.com', b'/stuff', b'', b'', b''))
self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff?query#fragment"),[](#l1.17)
(b'x-newscheme', b'foo.com', b'/stuff', b'', b'query', b'fragment'))[](#l1.18)
self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff?query"),[](#l1.19)
(b'x-newscheme', b'foo.com', b'/stuff', b'', b'query', b''))[](#l1.20)
def test_mixed_types_rejected(self): # Several functions that process either strings or ASCII encoded bytes
--- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -44,16 +44,9 @@ uses_netloc = ['ftp', 'http', 'gopher', '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'][](#l2.8)
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', ''][](#l2.13)
-uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news',
'nntp', 'wais', 'https', 'shttp', 'snews',[](#l2.15)
'file', 'prospero', ''][](#l2.16)
Characters valid in scheme names
scheme_chars = ('abcdefghijklmnopqrstuvwxyz' @@ -357,9 +350,9 @@ def urlsplit(url, scheme='', allow_fragm if (('[' in netloc and ']' not in netloc) or (']' in netloc and '[' not in netloc)): raise ValueError("Invalid IPv6 URL")
- if '?' in url: url, query = url.split('?', 1) v = SplitResult(scheme, netloc, url, query, fragment) _parse_cache[key] = v
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -63,6 +63,9 @@ Core and Builtins Library ------- +- Issue #9374: Generic parsing of query and fragment portions of url for any