Repository navigation
pathlib mistakenly assumes os.getcwd() is a resolved path in Windows #87621
Description
Activity
pathlib._WindowsFlavour.resolve() mistakenly assume that os.getcwd() returns a resolved path in Windows:
s = str(path) if not s: return os.getcwd()
I don't think this is a practical problem since
str(path)should never be an empty string. But if there is a concern that the result is an empty string, the code should uses = str(path) or '.', and resolve "." like any other relative path.In POSIX the result of getcwd() "shall contain no components that are dot or dot-dot, or are symbolic links". In Windows, os.getcwd() calls WinAPI GetCurrentDirectoryW(), which returns a fully-qualified path that may contain symbolic components that would be resolved in a final path. This includes filesystem symlinks and bind mounts (junctions), as well as mapped and substitute drives (i.e. drives that resolve to a filesystem directory instead of a volume device).
- added3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of life3.10 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Mar 9, 2021 I believe this has been fixed in #25264
I never had a practical case for
not s, since it's at least ".". Anyway, this is a non-issue now. It was only kept open for 3.8 and 3.9, and the last bugfix for 3.9 was released on 2022-05-17.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: