summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ntpath.py2
-rw-r--r--Lib/posixpath.py2
-rw-r--r--Lib/test/test_ntpath.py1
-rw-r--r--Lib/test/test_posixpath.py1
4 files changed, 6 insertions, 0 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index fa2fc29970..c4a4ac5f70 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -490,4 +490,6 @@ def relpath(path, start=curdir):
i += 1
rel_list = [pardir] * (len(start_list)-i) + path_list[i:]
+ if not rel_list:
+ return curdir
return join(*rel_list)
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index ee763ad254..ee6d0f2407 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -398,4 +398,6 @@ def relpath(path, start=curdir):
i = len(commonprefix([start_list, path_list]))
rel_list = [pardir] * (len(start_list)-i) + path_list[i:]
+ if not rel_list:
+ return curdir
return join(*rel_list)
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index 6af9c85142..4c9a0c2f76 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -166,6 +166,7 @@ tester('ntpath.relpath("a", "../b")', '..\\'+currentdir+'\\a')
tester('ntpath.relpath("a/b", "../c")', '..\\'+currentdir+'\\a\\b')
tester('ntpath.relpath("a", "b/c")', '..\\..\\a')
tester('ntpath.relpath("//conky/mountpoint/a", "//conky/mountpoint/b/c")', '..\\..\\a')
+tester('ntpath.relpath("a", "a")', '.')
if errors:
raise TestFailed(str(errors) + " errors.")
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index 88aa68c5b3..46ac067263 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -501,6 +501,7 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.relpath("a", "../b"), "../"+curdir+"/a")
self.assertEqual(posixpath.relpath("a/b", "../c"), "../"+curdir+"/a/b")
self.assertEqual(posixpath.relpath("a", "b/c"), "../../a")
+ self.assertEqual(posixpath.relpath("a", "a"), ".")
finally:
os.getcwd = real_getcwd