Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/posixpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,10 @@ def _joinrealpath(path, rest, strict, seen):
def relpath(path, start=None):
"""Return a relative version of a path"""

path = os.fspath(path)
if not path:
raise ValueError("no path specified")

path = os.fspath(path)
if isinstance(path, bytes):
curdir = b'.'
sep = b'/'
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_posixpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ def test_relpath(self):
(real_getcwd, os.getcwd) = (os.getcwd, lambda: r"/home/user/bar")
try:
curdir = os.path.split(os.getcwd())[-1]
self.assertRaises(TypeError, posixpath.relpath, None)
self.assertRaises(ValueError, posixpath.relpath, "")
self.assertEqual(posixpath.relpath("a"), "a")
self.assertEqual(posixpath.relpath(posixpath.abspath("a")), "a")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Raise :exc:`TypeError` for non-paths in :func:`os.path.relpath()` on Unix.