-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-123135: add support for path-like objects in fnmatch.filter
on POSIX platforms
#123122
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-123135: add support for path-like objects in fnmatch.filter
on POSIX platforms
#123122
Conversation
Users might already expect that
And the
And the
So I think we should fix the discrepancy and explicitly support path-like names. |
Let's fix it then. I think I'll make it a bugfix rather than a feature. |
fnmatch.filter
behavioursfnmatch.filter
See pythongh-123122 for the rationale.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. It's worth a .. versionchanged::
directive in the docs to point out that path-like support was added in 3.14, and that in previous versions it only worked on Windows.
Misc/NEWS.d/next/Library/2024-08-19-09-36-50.gh-issue-123135.w_ZNAs.rst
Outdated
Show resolved
Hide resolved
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
I have made the requested changes; please review again. By the way, I'm wondering whether we should explicitly call def fnmatchcase(name, pat):
"""Test whether FILENAME matches PATTERN, including case.
This is a version of fnmatch() which doesn't case-normalize
its arguments.
"""
match = _compile_pattern(pat)
- return match(name) is not None
+ return match(os.fspath(name)) is not None |
Thanks for making the requested changes! @barneygale: please review the changes made to this pull request. |
fnmatch.filter
fnmatch.filter
on POSIX platforms
@@ -0,0 +1,3 @@ | ||
Added support for supplying :term:`path-like objects <path-like object>` | ||
to the *names* parameter of :func:`fnmatch.filter`. Previously, such | ||
objects were only accepted on non-POSIX platforms. Patch by Bénédikt Tran. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only non-POSIX platform that we support is Windows:
objects were only accepted on non-POSIX platforms. Patch by Bénédikt Tran. | |
objects were only accepted on Windows. Patch by Bénédikt Tran. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about WASI?
That sounds reasonable to me! |
See #123215 (comment) for the rationale of marking it as DO-NOT-MERGE for now. |
See #123215 (comment) for the rationale of closing this PR. |
This fixes an inconsistency in the
fnmatch
module where path-like objects are allowed on Windows but not on POSIX platforms.cc @barneygale since you were recently interested in
fnmatch
!fnmatch.filter
on POSIX platforms #123135