]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-73991: Add `pathlib.Path.rmtree()` (#119060)
authorBarney Gale <barney.gale@gmail.com>
Sat, 20 Jul 2024 20:14:13 +0000 (21:14 +0100)
committerGitHub <noreply@github.com>
Sat, 20 Jul 2024 20:14:13 +0000 (20:14 +0000)
commit094375b9b7e087a4f0f60541dc7f2dc53be92646
tree77078617f44b03e728d48c7ade0b6986c6ef40d3
parent8db5f480072421bb065d346c3bbc5e88fc368587
GH-73991: Add `pathlib.Path.rmtree()` (#119060)

Add a `Path.rmtree()` method that removes an entire directory tree, like
`shutil.rmtree()`. The signature of the optional *on_error* argument
matches the `Path.walk()` argument of the same name, but differs from the
*onexc* and *onerror* arguments to `shutil.rmtree()`. Consistency within
pathlib is probably more important.

In the private pathlib ABCs, we add an implementation based on `walk()`.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Doc/library/pathlib.rst
Doc/whatsnew/3.14.rst
Lib/pathlib/_abc.py
Lib/pathlib/_local.py
Lib/test/test_pathlib/test_pathlib.py
Lib/test/test_pathlib/test_pathlib_abc.py
Misc/NEWS.d/next/Library/2024-05-15-01-21-44.gh-issue-73991.bNDqQN.rst [new file with mode: 0644]