From: Guido van Rossum Date: Mon, 14 Oct 2002 19:59:54 +0000 (+0000) Subject: Fix for 1.33: urlsplit() should only add '//' if scheme != ''. X-Git-Tag: v2.3c1~3781 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bbc0568a5c7d3849a22c78d545823a4b952c0933;p=thirdparty%2FPython%2Fcpython.git Fix for 1.33: urlsplit() should only add '//' if scheme != ''. Will add test and backport. --- diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index b82187939797..39f50e4ac074 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -27,7 +27,12 @@ class UrlParseTestCase(unittest.TestCase): self.assertEqual(result2, url) def checkJoin(self, base, relurl, expected): - self.assertEqual(urlparse.urljoin(base, relurl), expected) + self.assertEqual(urlparse.urljoin(base, relurl), expected, + (base, relurl, expected)) + + def test_unparse_parse(self): + for u in ['Python', './Python']: + self.assertEqual(urlparse.urlunparse(urlparse.urlparse(u)), u) def test_RFC1808(self): # "normal" cases from RFC 1808: diff --git a/Lib/urlparse.py b/Lib/urlparse.py index 6361937a9319..777b42f70373 100644 --- a/Lib/urlparse.py +++ b/Lib/urlparse.py @@ -128,7 +128,7 @@ def urlunparse((scheme, netloc, url, params, query, fragment)): return urlunsplit((scheme, netloc, url, query, fragment)) def urlunsplit((scheme, netloc, url, query, fragment)): - if netloc or (scheme in uses_netloc and url[:2] != '//'): + if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'): if url and url[:1] != '/': url = '/' + url url = '//' + (netloc or '') + url if scheme: