mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
[3.13] GH-89727: Partially fix shutil.rmtree()
recursion error on deep 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 a150679f90
)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
c3cfc04a73
commit
061abf8e4c
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