Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Feb 17, 2023

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented Jan 27, 2023

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 can't be readily backported as it relies on a feature of pathlib in 3.12: support for non-alphabetic drive letters when parsing paths.

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.
@eryksun
Copy link
Contributor

eryksun commented Jan 28, 2023

support for non-alphabetic drive letters when parsing paths.

We need a test in "test_ntpath.py" to ensure that splitroot(' :/foo') == (' :', '/', 'foo') and splitroot('/:/foo') == ('', '/', ':/foo').

WinAPI GetFullPathNameW() will accept any character in the 16-bit BMP as a drive 'letter', except for null, slash, and backslash. For example:

>>> os.getcwd()
'C:\\Temp'
>>> nt._getfullpathname(' :/foo')
' :\\foo'
>>> nt._getfullpathname('/:/foo')
'C:\\:\\foo'

@zooba
Copy link
Member

zooba commented Feb 16, 2023

Change looks fine, just rerunning the failed tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants