[3.13] GH-89727: Fix shutil.rmtree() recursion error on deep trees (GH-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 a150679f90.

(cherry picked from commit 53b1981fb0)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-06-01 21:38:55 +02:00 committed by GitHub
parent 99d0f51e61
commit 225c3cd6c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 68 additions and 97 deletions

View file

@ -741,7 +741,6 @@ class TestRmTree(BaseTest, unittest.TestCase):
shutil.rmtree(TESTFN)
raise
@unittest.skipIf(shutil._use_fd_functions, "fd-based functions remain unfixed (GH-89727)")
def test_rmtree_above_recursion_limit(self):
recursion_limit = 40
# directory_depth > recursion_limit