Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-110109: Fix misleading pathlib._abc.PurePathBase repr #113376

Merged
merged 1 commit into from
Dec 22, 2023

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented Dec 21, 2023

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 PR moves the __repr__() method to PurePath, leaving PurePathBase with the default object repr.

No user-facing changes because the pathlib._abc module remains private.

Downstream pathlib_abc issue: barneygale/pathlib-abc#6

`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.
@barneygale
Copy link
Contributor Author

Thanks very much for the review @serhiy-storchaka

@barneygale barneygale merged commit 237e2cf into python:main Dec 22, 2023
32 checks passed
ryan-duve pushed a commit to ryan-duve/cpython that referenced this pull request Dec 26, 2023
…hon#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.
kulikjak pushed a commit to kulikjak/cpython that referenced this pull request Jan 22, 2024
…hon#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.
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…hon#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants