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

GH-70303: Make pathlib.Path.glob('**') return both files and directories #114684

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented Jan 28, 2024

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/

…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.
Copy link
Member

@jaraco jaraco left a comment

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
Copy link
Member

zooba commented Jan 29, 2024

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 barneygale merged commit fda7445 into python:main Jan 30, 2024
29 checks passed
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants