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
glob.glob handling of * (asterisk) wildcard is broken #88546
Comments
Problem:
However, it stops short of saying that shell-style wildcards are handled the same way as in a POSIX-compliant/friendly shell. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_02 POSIX requires that " However, Reproduction: $ ls *.bash_profile
.bash_profile
$ python3 -c 'import glob; print(glob.glob("*.bash_profile"))'
[]
$ python3 -c 'import glob; print(glob.glob(".bash_profile"))'
['.bash_profile'] |
Only pattern beginning with a dot can match filename beginning with a dot. From https://docs.python.org/3/library/glob.html Note that unlike fnmatch.fnmatch(), glob treats filenames beginning with a dot (.) as special cases. This phrase was added in bpo-16695 in attempt to improve documentation, but it is still not clear. |
I may be naive, but why then: $ python3 -c 'from pathlib import Path; print(list(Path(".").glob("*.bash_profile")))' Outputs: [PosixPath('.bash_profile')] ? |
Sadly, this because pathlib glob and glob.glob use different implementations. And glob.glob does not provide something equivalent to a DOTALL flag allowing a user to glob hidden files without explicitly defining the leading dot in the pattern. |
I see now, said a blind man. |
…eordered sentence (pythonGH-91614) (cherry picked from commit b9ab6ce) Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
…eordered sentence (pythonGH-91614) (cherry picked from commit b9ab6ce) Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
While a little surprising, this has been the behaviour of |
…eordered sentence (pythonGH-91614) (cherry picked from commit b9ab6ce) Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: