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

pathlib.WindowsPath.glob() preserves case of literal pattern segments #104114

Closed
barneygale opened this issue May 3, 2023 · 1 comment
Closed
Labels
3.12 bugs and security fixes topic-pathlib type-bug An unexpected behavior, bug, or error

Comments

@barneygale
Copy link
Contributor

barneygale commented May 3, 2023

When pathlib.WindowsPath.glob() evaluates a literal (non-wildcard) pattern segment, it returns paths using the case of the pattern segment, rather than the real filesystem case. This problem does not affect segments involving * or ** wildcards.

>>> from pathlib import WindowsPath
>>> next(WindowsPath().glob('LIB/PATHLIB.*'))
WindowsPath('LIB/pathlib.py')  # 'LIB' should be 'Lib'

Linked PRs

@barneygale barneygale added type-bug An unexpected behavior, bug, or error 3.12 bugs and security fixes topic-pathlib labels May 3, 2023
barneygale added a commit to barneygale/cpython that referenced this issue May 3, 2023
…ern segment case

We now use `_WildcardSelector` to evaluate literal pattern segments, which
allows us to retrieve the real filesystem case.

This change is necessary in order to implement a *case_sensitive* argument
(see pythonGH-81079) and a *follow_symlinks* argument (see pythonGH-77609).
barneygale added a commit to barneygale/cpython that referenced this issue May 3, 2023
barneygale added a commit that referenced this issue May 3, 2023
…gment case (GH-104116)

We now use `_WildcardSelector` to evaluate literal pattern segments, which
allows us to retrieve the real filesystem case.

This change is necessary in order to implement a *case_sensitive* argument
(see GH-81079) and a *follow_symlinks* argument (see GH-77609).
@barneygale
Copy link
Contributor Author

Fixed in 3.12. Not backported as it relies on other changes in the 3.12 line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes topic-pathlib type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant