summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2024-01-26 01:12:46 (GMT)
committerGitHub <noreply@github.com>2024-01-26 01:12:46 (GMT)
commitb69548a0f52418b8a2cf7c7a885fdd7d3bfb1b0b (patch)
tree9f28d0deaeeb3d31f479cd31d255244ebd700f98 /Doc/whatsnew
parent841eacd07646e643f87d7f063106633a25315910 (diff)
downloadcpython-b69548a0f52418b8a2cf7c7a885fdd7d3bfb1b0b.zip
cpython-b69548a0f52418b8a2cf7c7a885fdd7d3bfb1b0b.tar.gz
cpython-b69548a0f52418b8a2cf7c7a885fdd7d3bfb1b0b.tar.bz2
GH-73435: Add `pathlib.PurePath.full_match()` (#114350)
In 49f90ba we added support for the recursive wildcard `**` in `pathlib.PurePath.match()`. This should allow arbitrary prefix and suffix matching, like `p.match('foo/**')` or `p.match('**/foo')`, but there's a problem: for relative patterns only, `match()` implicitly inserts a `**` token on the left hand side, causing all patterns to match from the right. As a result, it's impossible to match relative patterns from the left: `PurePath('foo/bar').match('bar/**')` is true! This commit reverts the changes to `match()`, and instead adds a new `full_match()` method that: - Allows empty patterns - Supports the recursive wildcard `**` - Matches the *entire* path when given a relative pattern
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/3.13.rst3
1 files changed, 2 insertions, 1 deletions
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index 40f0cd3..8c2bb05 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -336,7 +336,8 @@ pathlib
object from a 'file' URI (``file:/``).
(Contributed by Barney Gale in :gh:`107465`.)
-* Add support for recursive wildcards in :meth:`pathlib.PurePath.match`.
+* Add :meth:`pathlib.PurePath.full_match` for matching paths with
+ shell-style wildcards, including the recursive wildcard "``**``".
(Contributed by Barney Gale in :gh:`73435`.)
* Add *follow_symlinks* keyword-only argument to :meth:`pathlib.Path.glob`,