gh-101360: Fix anchor matching in pathlib.PureWindowsPath.match() (GH-101363)

Use `fnmatch` to match path and pattern anchors, just as we do for other
path parts. This allows patterns such as `'*:/Users/*'` to be matched.
This commit is contained in:
Barney Gale 2023-02-17 14:05:38 +00:00 committed by GitHub
parent 775f8819e3
commit d401b20630
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View file

@ -647,15 +647,10 @@ class PurePath(object):
drv, root, pat_parts = self._parse_parts((path_pattern,))
if not pat_parts:
raise ValueError("empty pattern")
elif drv and drv != self._flavour.normcase(self._drv):
return False
elif root and root != self._root:
return False
parts = self._parts_normcase
if drv or root:
if len(pat_parts) != len(parts):
return False
pat_parts = pat_parts[1:]
elif len(pat_parts) > len(parts):
return False
for part, pat in zip(reversed(parts), reversed(pat_parts)):