-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #23646: relpath recognizes Windows drive letters #38259
Conversation
Can somebody review this? |
Thanks, this does improve the situation, but I think there are still issues we need to resolve with |
In particular relpath("d:x","d:a/b/c") returns "..\\..\\..\\d:x" but should return "..\\..\\..\\x" ("d:a/b/c" is a relative path in the current directory in the d drive) |
The code should now correctly handle drive prefixes in relative paths, as verified by additional tests. I did not implement throwing relpath("d:x","d:a/b/c") == "..\\..\\..\\x"
relpath("c:/Users/vavasis/Documents", "E:/") == "c:\\Users\\vavasis\\Documents"
relpath("D","d") == "..\\D"
relpath("d:\\x", "D:\\x") == "."
relpath("c:/Users/vavasis/Documents", "C:/users/vavasis/Documents") == "..\\..\\..\\Users\\vavasis\\Documents"
relpath("c:/Users/vavasis/Documents", "c:/users/vavasis/Documents") == "..\\..\\..\\Users\\vavasis\\Documents" |
Can you add to the doc string about case insensitive of drive letters on Windows and also that if there's a drive mismatch we return the first path? |
Done. |
Fixes #23646.
This pull introduces two changes in behavior of
relpath
. All changes and tests should apply only to platforms on whichSys.iswindows()
is true.relpath(a,b)
wherea
andb
are from different Windows drives,abspath(a)
is returned.relpath("C:\\a", "c:\\") == "..\\C:\\a"
.