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-89727: Partially fix shutil.rmtree() recursion error on deep trees #119634

Merged
merged 7 commits into from
May 29, 2024

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented May 27, 2024

Make shutil._rmtree_unsafe() call os.walk(), which is implemented without recursion.

shutil._rmtree_safe_fd() is not affected and can still raise a recursion error.

…ep trees

Make `shutil._rmtree_unsafe()` call `os.walk()`, which is implemented
without recursion.

`shutil._rmtree_safe_fd()` is not affected and can still raise a recursion
error.
@barneygale
Copy link
Contributor Author

I've added the 'skip news' label because this is only a partial fix. Hopefully that's right!

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks. I think this should have a NEWS entry since it does change a user-visible behavior.

Lib/shutil.py Outdated Show resolved Hide resolved
Lib/shutil.py Outdated Show resolved Hide resolved
…PTTW.rst

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@barneygale
Copy link
Contributor Author

Thank you Jelle!

@barneygale barneygale enabled auto-merge (squash) May 29, 2024 19:49
@barneygale barneygale merged commit a150679 into python:main May 29, 2024
33 checks passed
@miss-islington-app
Copy link

Thanks @barneygale for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 29, 2024
…ep trees (pythonGH-119634)

Make `shutil._rmtree_unsafe()` call `os.walk()`, which is implemented
without recursion.

`shutil._rmtree_safe_fd()` is not affected and can still raise a recursion
error.

(cherry picked from commit a150679)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
@miss-islington-app
Copy link

Sorry, @barneygale, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker a150679f90c6e3f017bd75cac3b8f727063cc4aa 3.12

@bedevere-app
Copy link

bedevere-app bot commented May 29, 2024

GH-119748 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label May 29, 2024
barneygale added a commit to barneygale/cpython that referenced this pull request May 29, 2024
…ep trees (python#119634)

Make `shutil._rmtree_unsafe()` call `os.walk()`, which is implemented
without recursion.

`shutil._rmtree_safe_fd()` is not affected and can still raise a recursion
error.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit a150679)
barneygale added a commit to barneygale/cpython that referenced this pull request May 29, 2024
…r on deep trees (pythonGH-119634)

Make `shutil._rmtree_unsafe()` call `os.walk()`, which is implemented
without recursion.

`shutil._rmtree_safe_fd()` is not affected and can still raise a recursion
error.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>.
(cherry picked from commit a150679)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented May 29, 2024

GH-119749 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label May 29, 2024
barneygale added a commit that referenced this pull request May 29, 2024
…eep trees (GH-119634) (#119748)

GH-89727: Partially fix `shutil.rmtree()` recursion error on deep trees (GH-119634)

Make `shutil._rmtree_unsafe()` call `os.walk()`, which is implemented
without recursion.

`shutil._rmtree_safe_fd()` is not affected and can still raise a recursion
error.

(cherry picked from commit a150679)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
barneygale added a commit that referenced this pull request May 29, 2024
…eep trees (GH-119634) (#119749)

* GH-89727: Partially fix `shutil.rmtree()` recursion error on deep trees (#119634)

Make `shutil._rmtree_unsafe()` call `os.walk()`, which is implemented
without recursion.

`shutil._rmtree_safe_fd()` is not affected and can still raise a recursion
error.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit a150679)
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
…ep trees (python#119634)

Make `shutil._rmtree_unsafe()` call `os.walk()`, which is implemented
without recursion.

`shutil._rmtree_safe_fd()` is not affected and can still raise a recursion
error.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
…ep trees (python#119634)

Make `shutil._rmtree_unsafe()` call `os.walk()`, which is implemented
without recursion.

`shutil._rmtree_safe_fd()` is not affected and can still raise a recursion
error.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants