aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/modsupport.c
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2025-02-21 17:47:45 +0000
committerGitHub <noreply@github.com>2025-02-21 17:47:45 +0000
commitd88677ac20b9466387459d5adb2e87b7de64bc19 (patch)
tree46b17bbb56b0ecbe01e5596eaaf9b8888388660d /Python/modsupport.c
parent286c517db0fedf8d923d6f9620bcbbac4333880d (diff)
downloadcpython-d88677ac20b9466387459d5adb2e87b7de64bc19.tar.gz
cpython-d88677ac20b9466387459d5adb2e87b7de64bc19.zip
GH-128520: More consistent type-checking behaviour in pathlib (#130199)
In the following methods, skip casting of the argument to a path object if the argument has a `with_segments` attribute. In `PurePath`: `relative_to()`, `is_relative_to()`, `match()`, and `full_match()`. In `Path`: `rename()`, `replace()`, `copy()`, `copy_into()`, `move()`, and `move_into()`. Previously the check varied a bit from method to method. The `PurePath` methods used `isinstance(arg, PurePath)`; the `rename()` and `replace()` methods always cast, and the remaining `Path` methods checked for a private `_copy_writer` attribute. We apply identical changes to relevant methods of the private ABCs. This improves performance a bit, because `isinstance()` checks on ABCs are expensive.
Diffstat (limited to 'Python/modsupport.c')
0 files changed, 0 insertions, 0 deletions