GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

Conversation

@barneygale

@barneygale barneygale commented Jan 28, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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.

  • Issue: pathlib.glob('**') returns only directories #70303

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@barneygale
pythonGH-70303: Make pathlib.Path.glob('**') return both files and …
e1be3cd
…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.
@barneygale barneygale added the topic-pathlib label Jan 28, 2024
@bedevere-app bedevere-app Bot added the awaiting core review label Jan 28, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Jan 28, 2024
pathlib.glob('**') returns only directories #70303
Closed
@barneygale
barneygale requested review from jaraco and zooba January 28, 2024 18:50
jaraco
jaraco approved these changes Jan 29, 2024
View reviewed changes

@jaraco jaraco left a comment

Copy link
Copy Markdown
Member

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.

Nice work. Love it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

barneygale reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Jan 29, 2024
@zooba

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 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@barneygale
whatsnew
54aadc9
@barneygale
barneygale merged commit fda7445 into python:main Jan 30, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Jan 30, 2024
@barneygale barneygale mentioned this pull request Jan 30, 2024
Glob behavior is inconsistent across libraries #106747
Closed
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@barneygale @aisk
pythonGH-70303: Make pathlib.Path.glob('**') return both files and …
375fde6
…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

Reviewers

@jaraco jaraco jaraco approved these changes
@zooba zooba Awaiting requested review from zooba

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

topic-pathlib

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@barneygale @zooba @jaraco
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.