diff options
author | Barney Gale <barney.gale@gmail.com> | 2022-12-23 22:52:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-23 22:52:23 (GMT) |
commit | a68e585c8b7b27323f67905868467ce0588a1dae (patch) | |
tree | b6a5151685291445590c584dd1f02c5c6684b9eb /Python/ceval_gil.c | |
parent | 5d84966cce6c596da22922a07f49bde959ff5201 (diff) | |
download | cpython-a68e585c8b7b27323f67905868467ce0588a1dae.zip cpython-a68e585c8b7b27323f67905868467ce0588a1dae.tar.gz cpython-a68e585c8b7b27323f67905868467ce0588a1dae.tar.bz2 |
gh-68320, gh-88302 - Allow for private `pathlib.Path` subclassing (GH-31691)
Users may wish to define subclasses of `pathlib.Path` to add or modify
existing methods. Before this change, attempting to instantiate a subclass
raised an exception like:
AttributeError: type object 'PPath' has no attribute '_flavour'
Previously the `_flavour` attribute was assigned as follows:
PurePath._flavour = xxx not set!! xxx
PurePosixPath._flavour = _PosixFlavour()
PureWindowsPath._flavour = _WindowsFlavour()
This change replaces it with a `_pathmod` attribute, set as follows:
PurePath._pathmod = os.path
PurePosixPath._pathmod = posixpath
PureWindowsPath._pathmod = ntpath
Functionality from `_PosixFlavour` and `_WindowsFlavour` is moved into
`PurePath` as underscored-prefixed classmethods. Flavours are removed.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Eryk Sun <eryksun@gmail.com>
Diffstat (limited to 'Python/ceval_gil.c')
0 files changed, 0 insertions, 0 deletions