]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-73435: Implement recursive wildcards in `pathlib.PurePath.match()` (#101398)
authorBarney Gale <barney.gale@gmail.com>
Tue, 30 May 2023 20:18:09 +0000 (21:18 +0100)
committerGitHub <noreply@github.com>
Tue, 30 May 2023 20:18:09 +0000 (20:18 +0000)
commit49f90ba1eae56708b1894441418c13ad8e8ea9a8
tree84113e0493e1d74e6f6dce582e827dc8a155540b
parent4c770617c0feae18ce3b05e0c8acd0910acc7082
GH-73435: Implement recursive wildcards in `pathlib.PurePath.match()` (#101398)

`PurePath.match()` now handles the `**` wildcard as in `Path.glob()`, i.e. it matches any number of path segments.

We now compile a `re.Pattern` object for the entire pattern. This is made more difficult by `fnmatch` not treating directory separators as special when evaluating wildcards (`*`, `?`, etc), and so we arrange the path parts onto separate *lines* in a string, and ensure we don't set `re.DOTALL`.

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Doc/library/pathlib.rst
Doc/whatsnew/3.13.rst
Lib/pathlib.py
Lib/test/test_pathlib.py
Misc/NEWS.d/next/Library/2023-02-17-18-56-46.gh-issue-73435.7sTJHk.rst [new file with mode: 0644]