diff -r b428b803f71f Lib/ntpath.py --- a/Lib/ntpath.py Tue Apr 22 21:54:10 2014 -0400 +++ b/Lib/ntpath.py Thu Apr 24 02:36:14 2014 -0400 @@ -498,7 +498,7 @@ rel_list = [pardir] * (len(start_list)-i) + path_list[i:] if not rel_list: - return curdir + return curdir if isinstance(path, str) else curdir.decode() return join(*rel_list) try: diff -r b428b803f71f Lib/posixpath.py --- a/Lib/posixpath.py Tue Apr 22 21:54:10 2014 -0400 +++ b/Lib/posixpath.py Thu Apr 24 02:36:14 2014 -0400 @@ -442,5 +442,5 @@ rel_list = [pardir] * (len(start_list)-i) + path_list[i:] if not rel_list: - return curdir + return curdir if isinstance(path, str) else curdir.decode() return join(*rel_list) diff -r b428b803f71f Lib/test/test_ntpath.py --- a/Lib/test/test_ntpath.py Tue Apr 22 21:54:10 2014 -0400 +++ b/Lib/test/test_ntpath.py Thu Apr 24 02:36:14 2014 -0400 @@ -250,6 +250,10 @@ tester('ntpath.relpath("/a/b", "/a/b")', '.') tester('ntpath.relpath("c:/foo", "C:/FOO")', '.') + def test_relpath_return_type_consistent_with_input(self): + self.assertTrue(isinstance(os.path.relpath('.', '..'), str)) + self.assertTrue(isinstance(os.path.relpath(u'.', u'..'), unicode)) + self.assertTrue(isinstance(os.path.relpath(u'.', u'.'), unicode)) class NtCommonTest(test_genericpath.CommonTest): pathmodule = ntpath diff -r b428b803f71f Lib/test/test_posixpath.py --- a/Lib/test/test_posixpath.py Tue Apr 22 21:54:10 2014 -0400 +++ b/Lib/test/test_posixpath.py Thu Apr 24 02:36:14 2014 -0400 @@ -409,6 +409,11 @@ finally: os.getcwd = real_getcwd + def test_relpath_return_type_consistent_with_input(self): + self.assertTrue(isinstance(posixpath.relpath('.', '..'), str)) + self.assertTrue(isinstance(posixpath.relpath(u'.', u'..'), unicode)) + self.assertTrue(isinstance(posixpath.relpath(u'.', u'.'), unicode)) + class PosixCommonTest(test_genericpath.CommonTest): pathmodule = posixpath