Index: Lib/test/test_urlparse.py =================================================================== --- Lib/test/test_urlparse.py (revision 78212) +++ Lib/test/test_urlparse.py (working copy) @@ -353,6 +353,13 @@ self.assertEqual(urlparse.urlparse("http://example.com?blahblah=/foo"), ('http', 'example.com', '', '', 'blahblah=/foo', '')) + def test_anyscheme(self): + # Issue 7904: s3://foo.com/stuff has netloc "foo.com". + self.assertEqual(urlparse.urlparse("s3://foo.com/stuff"), + ('s3', 'foo.com', '/stuff', '', '', '')) + self.assertEqual(urlparse.urlparse("x-newscheme://foo.com/stuff"), + ('x-newscheme', 'foo.com', '/stuff', '', '', '')) + def test_main(): test_support.run_unittest(UrlParseTestCase) Index: Lib/urlparse.py =================================================================== --- Lib/urlparse.py (revision 78212) +++ Lib/urlparse.py (working copy) @@ -2,6 +2,7 @@ See RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June 1995. +RFC 3986: "Uniform Resource Identifier (URI): Generic Syntax", January 2005. """ __all__ = ["urlparse", "urlunparse", "urljoin", "urldefrag", @@ -14,7 +15,7 @@ uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet', 'imap', 'wais', 'file', 'mms', 'https', 'shttp', 'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '', - 'svn', 'svn+ssh', 'sftp','nfs'] + 'svn', 'svn+ssh', 'sftp','nfs', 's3'] non_hierarchical = ['gopher', 'hdl', 'mailto', 'news', 'telnet', 'wais', 'imap', 'snews', 'sip', 'sips'] uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap', @@ -163,7 +164,7 @@ break else: scheme, url = url[:i].lower(), url[i+1:] - if scheme in uses_netloc and url[:2] == '//': + if url[:2] == '//': netloc, url = _splitnetloc(url, 2) if allow_fragments and scheme in uses_fragment and '#' in url: url, fragment = url.split('#', 1)