-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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-129350: Make tests for glob with trailing slash more strict #129376
gh-129350: Make tests for glob with trailing slash more strict #129376
Conversation
Test that the trailing pathname separator is preserved. Multiple trailing pathname separators are only preserved if the pattern does not contain metacharacters, otherwise only one trailing pathname separator is preserved. This is rather an implementation detail.
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.
LGTM. Interesting that the results for patterns ending sep*2
differ depending on whether the preceding part involves a wildcard or not - is there another bug there do you think?
Normalizing separators to |
Stripping or preserving the redundant pathname separators is an implementation detail. User code can rely on that details, so it is better to test them to avoid unintentional changes. There are other implementation details (normalizing the separator on Windows, the case of the names on Windows). There is an open issue for some of them, but I do not think that we can do something without sacrificing performance or breaking user code. I'll add comments clarifying what is an implementation detail. |
It strikes me as an (extremely minor) bug rather than an implementation detail, especially as it differs from shell globbing behaviour. But probably not worth fixing. |
This is the same in shell: $ echo /usr/bin//
/usr/bin//
$ echo /usr/b*//
/usr/bin/
$ echo /u*/bin//
/usr/bin/ |
There are some cases that aren't consistent: $ echo /usr//b*
/usr//bin
$ python3 -c 'import glob; print(glob.glob("/usr//b*"))'
['/usr/bin'] |
Which shell?
|
This is a different implementation detail, not related to this PR. For |
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
…ythonGH-129376) Test that the trailing pathname separator is preserved. Multiple trailing pathname separators are only preserved if the pattern does not contain metacharacters, otherwise only one trailing pathname separator is preserved. This is rather an implementation detail. (cherry picked from commit 8b5c850) Co-authored-by: Serhiy Storchaka <[email protected]>
GH-129651 is a backport of this pull request to the 3.13 branch. |
…ythonGH-129376) Test that the trailing pathname separator is preserved. Multiple trailing pathname separators are only preserved if the pattern does not contain metacharacters, otherwise only one trailing pathname separator is preserved. This is rather an implementation detail. (cherry picked from commit 8b5c850) Co-authored-by: Serhiy Storchaka <[email protected]>
GH-129652 is a backport of this pull request to the 3.12 branch. |
…GH-129376) (GH-129652) Test that the trailing pathname separator is preserved. Multiple trailing pathname separators are only preserved if the pattern does not contain metacharacters, otherwise only one trailing pathname separator is preserved. This is rather an implementation detail. (cherry picked from commit 8b5c850) Co-authored-by: Serhiy Storchaka <[email protected]>
…GH-129376) (GH-129651) Test that the trailing pathname separator is preserved. Multiple trailing pathname separators are only preserved if the pattern does not contain metacharacters, otherwise only one trailing pathname separator is preserved. This is rather an implementation detail. (cherry picked from commit 8b5c850) Co-authored-by: Serhiy Storchaka <[email protected]>
…ythonGH-129376) Test that the trailing pathname separator is preserved. Multiple trailing pathname separators are only preserved if the pattern does not contain metacharacters, otherwise only one trailing pathname separator is preserved. This is rather an implementation detail.
…ythonGH-129376) Test that the trailing pathname separator is preserved. Multiple trailing pathname separators are only preserved if the pattern does not contain metacharacters, otherwise only one trailing pathname separator is preserved. This is rather an implementation detail.
Test that the trailing pathname separator is preserved.
Multiple trailing pathname separators are only preserved if the pattern does not contain metacharacters, otherwise only one trailing pathname separator is preserved. This is rather an implementation detail.
glob.py
#129350