summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2023-05-05 19:04:53 (GMT)
committerGitHub <noreply@github.com>2023-05-05 19:04:53 (GMT)
commitd00d94214971621e6a3541425ee8c8072023ca1a (patch)
treee439827cd482073748827bb73c3a46132dee89e1 /Doc/whatsnew
parent1afe0e0320c6f19418d44d682ad95ba0c689c595 (diff)
downloadcpython-d00d94214971621e6a3541425ee8c8072023ca1a.zip
cpython-d00d94214971621e6a3541425ee8c8072023ca1a.tar.gz
cpython-d00d94214971621e6a3541425ee8c8072023ca1a.tar.bz2
GH-100479: Add `pathlib.PurePath.with_segments()` (GH-103975)
Add `pathlib.PurePath.with_segments()`, which creates a path object from arguments. This method is called whenever a derivative path is created, such as from `pathlib.PurePath.parent`. Subclasses may override this method to share information between path objects. Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/3.12.rst5
1 files changed, 5 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst
index 4f952e2..ccddc8b 100644
--- a/Doc/whatsnew/3.12.rst
+++ b/Doc/whatsnew/3.12.rst
@@ -348,6 +348,11 @@ inspect
pathlib
-------
+* Add support for subclassing :class:`pathlib.PurePath` and
+ :class:`~pathlib.Path`, plus their Posix- and Windows-specific variants.
+ Subclasses may override the :meth:`~pathlib.PurePath.with_segments` method
+ to pass information between path instances.
+
* Add :meth:`~pathlib.Path.walk` for walking the directory trees and generating
all file or directory names within them, similar to :func:`os.walk`.
(Contributed by Stanislav Zmiev in :gh:`90385`.)