You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A relative rooted path specifies a drive, but its fully qualified path is resolved against the current directory.
So I think the relative rooted path should be something like C:foo (please notice that it's not C:/foo), but /foo still is an absolute path. And ntpath.isabs('/foo') returns True, so I think it's an absolute path.
The error message states: "Can't mix absolute and relative paths".
But /foo & foo are both relative according to ntpath.isabs():
Path
Rooted?
Absolute?
c:/foo
Yes
Yes
c:foo
Yes
No
/foo
Yes
No
foo
No
No
So, this error message is factually incorrect.
But /foo is rooted and foo is not, so that's what the new error message is in that case.
On a side note, it could be useful to add os.path.isrooted.
Activity
aisk commentedon Mar 30, 2024
I did some googling and found that Microsoft has a document which describes "relative rooted path": https://learn.microsoft.com/en-us/dotnet/api/system.io.path.ispathrooted?view=net-8.0#remarks
So I think the relative rooted path should be something like
C:foo(please notice that it's notC:/foo), but/foostill is an absolute path. Andntpath.isabs('/foo')returnsTrue, so I think it's an absolute path.nineteendo commentedon Mar 30, 2024
That was recently changed:
ntpath.isabs()handling of part-absolute paths #113829The error message could also be "Can't mix rooted and not-rooted paths" as
/foois rooted andfoois not.zooba commentedon Apr 2, 2024
How does this change make life better or easier for those encountering this message?
At first glance, it appears to be getting into overly precise terminology that doesn't help educate or correct the caller.
nineteendo commentedon Apr 2, 2024
The error message states: "Can't mix absolute and relative paths".
But
/foo&fooare both relative according tontpath.isabs():c:/fooc:foo/foofooSo, this error message is factually incorrect.
But
/foois rooted andfoois not, so that's what the new error message is in that case.On a side note, it could be useful to add
os.path.isrooted.gh-117381: Improve error messages for ntpath.commonpath() (GH-117382)
pythongh-117381: Improve error messages for ntpath.commonpath() (pyth…