mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
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.
This commit is contained in:
parent
45e09f921b
commit
237e2cff00
4 changed files with 16 additions and 15 deletions
|
|
@ -282,9 +282,6 @@ class PurePathBase:
|
|||
slashes."""
|
||||
return str(self).replace(self.pathmod.sep, '/')
|
||||
|
||||
def __repr__(self):
|
||||
return "{}({!r})".format(self.__class__.__name__, self.as_posix())
|
||||
|
||||
@property
|
||||
def drive(self):
|
||||
"""The drive prefix (letter or UNC path), if any."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue