Skip to content

gh-92550: Fix pathlib.Path.rglob() for empty pattern #92604

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

Merged

Conversation

serhiy-storchaka
Copy link
Member

Fixes #92550

@@ -1693,10 +1693,15 @@ def _check(glob, expected):
"dirA", "dirA/linkC", "dirB", "dirB/linkD", "dirC",
"dirC/dirD", "dirE", "linkB",
])
_check(p.rglob(""), ["", "dirA", "dirB", "dirC", "dirE", "dirC/dirD"])

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it should include the original directory for compatibility with the old code of Path.rglob() and with glob.glob(recursive=True).

@serhiy-storchaka serhiy-storchaka merged commit 87f849c into python:main May 11, 2022
@miss-islington
Copy link
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

@serhiy-storchaka serhiy-storchaka deleted the pathlib-rglob-empty-pattern branch May 11, 2022 04:43
@bedevere-bot
Copy link

GH-92657 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label May 11, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 11, 2022
…92604)

(cherry picked from commit 87f849c)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington added a commit that referenced this pull request May 11, 2022
(cherry picked from commit 87f849c)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pathlib.Path.rglob("") raises IndexError in Python 3.11b1
6 participants