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

GH-89727: Fix `shutil.rmtree()` recursion error on deep trees by barneygale · Pull Request #119808 · python/cpython · GitHub

Repository navigation

GH-89727: Fix shutil.rmtree() recursion error on deep trees - #119808

Merged
barneygale merged 13 commits into
python:mainfrom
barneygale:gh-89727-rmtree-safe
Jun 1, 2024
Merged

barneygale merged 13 commits into
python:mainfrom
barneygale:gh-89727-rmtree-safe

Conversation

barneygale commented May 30, 2024 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Implement shutil._rmtree_safe_fd() using a list as a stack to avoid emitting recursion errors on deeply nested trees.

shutil._rmtree_unsafe() was fixed in #119634.

Copy link
Copy Markdown
Contributor Author

I tried to implement this atop os.fwalk(), but I couldn't get it to work. There's not enough context around exceptions raised from os.fwalk() basically.

ambv left a comment

Copy link
Copy Markdown
Contributor

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

I like how this is more concise and protects against recursion errors. It's somewhat less obvious what's going on here now, I left some comments.

Comment thread Lib/shutil.py Outdated
Comment thread Lib/shutil.py Outdated
Comment thread Lib/shutil.py Outdated
Comment thread Lib/shutil.py

ambv left a comment

Copy link
Copy Markdown
Contributor

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

LGTM. I'll let Jelle comment and merge.

Comment thread Lib/shutil.py

barneygale commented Jun 1, 2024 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Thanks very much for the reviews, both! @JelleZijlstra can I merge, or would you like to do the honours as Łukasz suggested?

This will hit a conflict when backported to 3.12 due to a difference in FileNotFoundError handling. Should be an easy fix.

Copy link
Copy Markdown
Member

Feel free to merge yourself!

Copy link
Copy Markdown
Contributor Author

Super. Thanks again!

barneygale merged commit 53b1981 into python:main Jun 1, 2024

Copy link
Copy Markdown

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 Jun 1, 2024
…ythonGH-119808)

Implement `shutil._rmtree_safe_fd()` using a list as a stack to avoid emitting recursion errors on deeply nested trees.

`shutil._rmtree_unsafe()` was fixed in a150679.
(cherry picked from commit 53b1981)

Co-authored-by: Barney Gale <barney.gale@gmail.com>

bedevere-app Bot commented Jun 1, 2024

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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 53b1981fb0cda6c656069e992f172fc6aad7c99c 3.12

bedevere-app Bot removed the needs backport to 3.13 only security fixes label Jun 1, 2024
barneygale added a commit to barneygale/cpython that referenced this pull request Jun 1, 2024
…ython#119808)

Implement `shutil._rmtree_safe_fd()` using a list as a stack to avoid emitting recursion errors on deeply nested trees.

`shutil._rmtree_unsafe()` was fixed in a150679.

(cherry picked from commit 53b1981)
barneygale added a commit to barneygale/cpython that referenced this pull request Jun 1, 2024
…trees (pythonGH-119808)

Implement `shutil._rmtree_safe_fd()` using a list as a stack to avoid emitting recursion errors on deeply nested trees.

`shutil._rmtree_unsafe()` was fixed in a150679..
(cherry picked from commit 53b1981)

Co-authored-by: Barney Gale <barney.gale@gmail.com>

bedevere-app Bot commented Jun 1, 2024

Copy link
Copy Markdown

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

bedevere-app Bot removed the needs backport to 3.12 only security fixes label Jun 1, 2024
barneygale added a commit that referenced this pull request Jun 1, 2024
…H-119808) (#119918)

Implement `shutil._rmtree_safe_fd()` using a list as a stack to avoid emitting recursion errors on deeply nested trees.

`shutil._rmtree_unsafe()` was fixed in a150679.

(cherry picked from commit 53b1981)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
barneygale added a commit that referenced this pull request Jun 1, 2024
…H-119808) (#119919)

Implement `shutil._rmtree_safe_fd()` using a list as a stack to avoid emitting recursion errors on deeply nested trees.

`shutil._rmtree_unsafe()` was fixed in a150679.

(cherry picked from commit 53b1981)
barneygale added a commit to barneygale/cpython that referenced this pull request Jun 5, 2024
…ython#119808)

Implement `shutil._rmtree_safe_fd()` using a list as a stack to avoid emitting recursion errors on deeply nested trees.

`shutil._rmtree_unsafe()` was fixed in a150679.
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
…ython#119808)

Implement `shutil._rmtree_safe_fd()` using a list as a stack to avoid emitting recursion errors on deeply nested trees.

`shutil._rmtree_unsafe()` was fixed in a150679.
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
…ython#119808)

Implement `shutil._rmtree_safe_fd()` using a list as a stack to avoid emitting recursion errors on deeply nested trees.

`shutil._rmtree_unsafe()` was fixed in a150679.
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL