GH-70303: Make pathlib.Path.glob('**') return both files and directories by barneygale · Pull Request #114684 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation2 Commits2 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

barneygale

Return files and directories from pathlib.Path.glob() if the pattern ends with **. This is more compatible with PurePath.full_match() and with other glob implementations such as bash and glob.glob(). Users can add a trailing slash to match only directories.

In my previous PR I added a FutureWarning with the intention of fixing this in Python 3.15. Upon further reflection I think this was an unnecessarily cautious remedy to a clear bug.


📚 Documentation preview 📚: https://cpython-previews--114684.org.readthedocs.build/

@barneygale

…directories

Return files and directories from pathlib.Path.glob() if the pattern ends with **. This is more compatible with PurePath.full_match() and with other glob implementations such as bash and glob.glob(). Users can add a trailing slash to match only directories.

In my previous patch I added a FutureWarning with the intention of fixing this in Python 3.15. Upon further reflection I think this was an unnecessarily cautious remedy to a clear bug.

jaraco

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Love it.

@zooba

Agree we can fix this, but let's make sure it's clearly mentioned in What's New and Porting Notes (also on the What's New page) for 3.13. If that's already been done, consider me +1

@barneygale

aisk pushed a commit to aisk/cpython that referenced this pull request

Feb 11, 2024

@barneygale @aisk

…directories (python#114684)

Return files and directories from pathlib.Path.glob() if the pattern ends with **. This is more compatible with PurePath.full_match() and with other glob implementations such as bash and glob.glob(). Users can add a trailing slash to match only directories.

In my previous patch I added a FutureWarning with the intention of fixing this in Python 3.15. Upon further reflection I think this was an unnecessarily cautious remedy to a clear bug.