]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-110109: Fix misleading `pathlib._abc.PurePathBase` repr (#113376)
authorBarney Gale <barney.gale@gmail.com>
Fri, 22 Dec 2023 15:11:16 +0000 (15:11 +0000)
committerGitHub <noreply@github.com>
Fri, 22 Dec 2023 15:11:16 +0000 (15:11 +0000)
commit237e2cff00cca49db47bcb7ea13683a4d9ad1ea5
treef1d2f5db8d04d263b2c2b3808f31a800df4a45ac
parent45e09f921be55e23bed19b5db4c95ce7bd7aad6b
GH-110109: Fix misleading `pathlib._abc.PurePathBase` repr (#113376)

`PurePathBase.__repr__()` produces a string like `MyPath('/foo')`. This
repr is incorrect/misleading when a subclass's `__init__()` method is
customized, which I expect to be the very common.

This commit moves the `__repr__()` method to `PurePath`, leaving
`PurePathBase` with the default `object` repr.

No user-facing changes because the `pathlib._abc` module remains private.
Lib/pathlib/__init__.py
Lib/pathlib/_abc.py
Lib/test/test_pathlib/test_pathlib.py
Lib/test/test_pathlib/test_pathlib_abc.py