FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

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

/ cpython Public

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

Merged
barneygale merged 2 commits into
python:mainfrom
barneygale:gh-70303
Jan 30, 2024
Merged

GH-70303: Make pathlib.Path.glob('**') return both files and directories#114684
barneygale merged 2 commits into
python:mainfrom
barneygale:gh-70303

Conversation

barneygale commented Jan 28, 2024
edited
Loading

Copy link
Copy Markdown
Contributor

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.

jaraco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nice work. Love it.

zooba commented Jan 29, 2024

Copy link
Copy Markdown
Member

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 merged commit fda7445 into python:main Jan 30, 2024
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.
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
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


Back | FazBrowse Home | New Git URL