]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
pathlib ABCs: tighten up `resolve()` and `absolute()` (#126611)
authorBarney Gale <barney.gale@gmail.com>
Sat, 9 Nov 2024 18:47:49 +0000 (18:47 +0000)
committerGitHub <noreply@github.com>
Sat, 9 Nov 2024 18:47:49 +0000 (18:47 +0000)
commit266328552e922fd9030cd699e10a25f03a67c8ba
tree5a210ddb5613acd82d11e112959972ed4d4a7a84
parent0f47a3199c51ba7c49e72b4c645dbf599aa17be4
pathlib ABCs: tighten up `resolve()` and `absolute()` (#126611)

In `PathBase.resolve()`, raise `UnsupportedOperation` if a non-POSIX path
parser is used (our implementation uses `posixpath._realpath()`, which
produces incorrect results for non-POSIX path flavours.) Also tweak code to
call `self.absolute()` upfront rather than supplying an emulated `getcwd()`
function.

Adjust `PathBase.absolute()` to work somewhat like `resolve()`. If a POSIX
path parser is used, we treat the root directory as the current directory.
This is the simplest useful behaviour for concrete path types without a
current directory cursor.
Lib/pathlib/_abc.py
Lib/test/test_pathlib/test_pathlib.py
Lib/test/test_pathlib/test_pathlib_abc.py