0
0
mirror of https://github.com/python/cpython.git synced 2024-11-22 13:28:21 +01:00
cpython/Lib/pathlib
Barney Gale b69548a0f5
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
2024-01-26 01:12:46 +00:00
..
__init__.py GH-73435: Add pathlib.PurePath.full_match() (#114350) 2024-01-26 01:12:46 +00:00
_abc.py GH-73435: Add pathlib.PurePath.full_match() (#114350) 2024-01-26 01:12:46 +00:00