From dacbafb18af2ecc3c27ab566c80a9b4de743544d Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 14 Oct 2002 20:08:50 +0000 Subject: [PATCH] Backporting urlparse.py:1.34, test_urlparse.py:1.8: Fix for 1.33: urlsplit() should only add '//' if scheme != ''. [SF bug 620705] --- Lib/test/test_urlparse.py | 5 +++++ Lib/urlparse.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index 7651afab85f7..3ad49ef7f299 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -87,3 +87,8 @@ checkJoin('g/../h', 'http://a/b/c/h') #checkJoin('http:', 'http:') print errors, "errors" + +# One more test backported from 2.3 +for u in ['Python', './Python']: + if urlparse.urlunparse(urlparse.urlparse(u)) != u: + print "*** urlparse/urlunparse failure for", `u` 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: -- 2.47.3