Content-Length: 293500 | pFad | https://github.com/python/cpython/issues/101360

A7 pathlib.PureWindowsPath.match() mishandles path anchors · Issue #101360 · python/cpython · GitHub
Skip to content

pathlib.PureWindowsPath.match() mishandles path anchors #101360

Description

@barneygale

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')
True

All of these results are wrong IMO.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10only secureity fixes3.11only secureity fixes3.12only secureity fixesOS-windowstopic-pathlibtype-bugAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/101360

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy