diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py index 762500789f..641b772519 100644 --- a/Lib/test/test_urlparse.py +++ b/Lib/test/test_urlparse.py @@ -265,7 +265,6 @@ class UrlParseTestCase(unittest.TestCase): self.checkJoin(RFC1808_BASE, '../../g', 'http://a/g') # "abnormal" cases from RFC 1808: - self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q#f') self.checkJoin(RFC1808_BASE, 'g.', 'http://a/b/c/g.') self.checkJoin(RFC1808_BASE, '.g', 'http://a/b/c/.g') self.checkJoin(RFC1808_BASE, 'g..', 'http://a/b/c/g..') @@ -281,6 +280,7 @@ class UrlParseTestCase(unittest.TestCase): #self.checkJoin(RFC1808_BASE, 'http:', 'http:') # XXX: The following tests are no longer compatible with RFC3986 + # self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q#f') # self.checkJoin(RFC1808_BASE, '../../../g', 'http://a/../g') # self.checkJoin(RFC1808_BASE, '../../../../g', 'http://a/../../g') # self.checkJoin(RFC1808_BASE, '/./g', 'http://a/./g') @@ -449,6 +449,9 @@ class UrlParseTestCase(unittest.TestCase): # issue 23703: don't duplicate filename self.checkJoin('a', 'b', 'b') + # no base fragment for any url (not compatible with RFC1808) + self.checkJoin('http://a/b#f', '', 'http://a/b') + def test_RFC2732(self): str_cases = [ ('http://Test.python.org:5432/foo/', 'test.python.org', 5432), diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py index 779278bac5..58ffbe1c50 100644 --- a/Lib/urllib/parse.py +++ b/Lib/urllib/parse.py @@ -515,8 +515,6 @@ def urljoin(base, url, allow_fragments=True): interpretation of the latter.""" if not base: return url - if not url: - return base base, url, _coerce_result = _coerce_args(base, url) bscheme, bnetloc, bpath, bparams, bquery, bfragment = \