Repository navigation
Fix error message for ntpath.commonpath #117381
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Mar 29, 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
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 notC:/foo), but/foostill is an absolute path. Andntpath.isabs('/foo')returnsTrue, so I think it's an absolute path.ntpath.isabs('/foo')returnsTrueThat was recently changed:
The error message could also be "Can't mix rooted and not-rooted paths" as
/foois rooted andfoois not.Reacted by An LongHow 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.
The error message states: "Can't mix absolute and relative paths".
But/foo&fooare both relative according tontpath.isabs():Path Rooted? Absolute? c:/fooYes Yes c:fooYes No /fooYes No fooNo No So, 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 addos.path.isrooted.
Bug report
Bug description:
/foois not an absolute path, but a rooted path, which can't be mixed with not-rooted paths.CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
ntpath.commonpath#117382