]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
pathlib ABCs: restore `relative_to()` and `is_relative_to()` (#138853)
authorBarney Gale <barney.gale@gmail.com>
Fri, 10 Oct 2025 18:08:55 +0000 (19:08 +0100)
committerGitHub <noreply@github.com>
Fri, 10 Oct 2025 18:08:55 +0000 (19:08 +0100)
commit49aaee7978c54211967392678072accc403d15f2
tree167698d87bcce318cebfcd7e594371c208418842
parentb881df47ff1adca515d1de04f689160ddae72142
pathlib ABCs: restore `relative_to()` and `is_relative_to()` (#138853)

Restore `JoinablePath.[is_]relative_to()`, which were deleted in
ef63cca494571f50906baae1d176469a3dcf8838. These methods are too useful to
forgo. Restore old tests, and add new tests covering path classes with
non-overridden `__eq__()` and `__hash__()`.

Slightly simplify `PurePath.relative_to()` while we're in the area.

No change to public APIs, because the pathlib ABCs are still private.
Lib/pathlib/__init__.py
Lib/pathlib/types.py
Lib/test/test_pathlib/test_join.py