diff -r c84a0b35999a Lib/test/test_urlparse.py --- a/Lib/test/test_urlparse.py Thu Mar 19 15:24:27 2015 +0200 +++ b/Lib/test/test_urlparse.py Thu Mar 19 08:03:55 2015 -0700 @@ -391,6 +391,9 @@ self.checkJoin('http://a/b/c/d/e/', '../../f/g', 'http://a/b/c/f/g') self.checkJoin('http://a/b/', '../../f/g/', 'http://a/f/g/') + # issue23703 + self.checkJoin('a', 'b', 'b') + def test_RFC2732(self): str_cases = [ ('http://Test.python.org:5432/foo/', 'test.python.org', 5432), diff -r c84a0b35999a Lib/urllib/parse.py --- a/Lib/urllib/parse.py Thu Mar 19 15:24:27 2015 +0200 +++ b/Lib/urllib/parse.py Thu Mar 19 08:03:55 2015 -0700 @@ -445,8 +445,10 @@ segments = base_parts + path.split('/') # filter out elements that would cause redundant slashes on re-joining # the resolved_path - segments = segments[0:1] + [ - s for s in segments[1:-1] if len(s) > 0] + segments[-1:] + segs = segments[0:1] + [s for s in segments[1:-1] if s] + if len(segments) > 1: + segs.append(segments[-1]) + segments = segs resolved_path = []