mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
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>
This commit is contained in:
parent
c22323cd1c
commit
a150679f90
4 changed files with 33 additions and 28 deletions
|
@ -741,6 +741,17 @@ 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
|
||||
directory_depth = recursion_limit + 10
|
||||
base = os.path.join(TESTFN, *(['d'] * directory_depth))
|
||||
os.makedirs(base)
|
||||
|
||||
with support.infinite_recursion(recursion_limit):
|
||||
shutil.rmtree(TESTFN)
|
||||
|
||||
|
||||
class TestCopyTree(BaseTest, unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue