GH-89727: Fix shutil.rmtree() recursion error on deep trees (#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 a150679f90.
This commit is contained in:
Barney Gale 2024-06-01 19:49:12 +01:00 committed by GitHub
parent 63111bfcf0
commit 53b1981fb0
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