-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
pathlib.PureWindowsPath.match() mishandles path anchors #101360
Copy link
Copy link
Closed
Labels
3.10only security fixesonly security fixes3.11only security fixesonly security fixes3.12only security fixesonly security fixesOS-windowstopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
pathlib.PurePath.match() doesn't use fnmatch() to match path anchors, contrary to the documentation. Instead, it considers the drive and root of the pattern separately; if either (or both) is specified in the pattern, it must exactly match the corresponding drive/root in the path.
This results in the following:
>>> from pathlib import PureWindowsPath as P
>>> P('c:/b.py').match('*:/*.py')
False
>>> P('c:/b.py').match('c:*.py')
True
>>> P('c:/b.py').match('/*.py')
True
>>> P('//some/share/a.py').match('//*/*/*.py')
False
>>> P('//some/share/a.py').match('/*.py')
TrueAll of these results are wrong IMO.
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.10only security fixesonly security fixes3.11only security fixesonly security fixes3.12only security fixesonly security fixesOS-windowstopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error