]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
GH-73991: Use same signature for `shutil._rmtree_[un]safe()`. (#120517)
authorBarney Gale <barney.gale@gmail.com>
Tue, 18 Jun 2024 21:15:18 +0000 (22:15 +0100)
committerGitHub <noreply@github.com>
Tue, 18 Jun 2024 21:15:18 +0000 (22:15 +0100)
commit69058e20e420181abdc51094474f590d32cd7174
treef0817ea56ccf1461fb20f93f9ff62dbe17a8fa0c
parent49f51deeef901b677853f00e428cbaeb13ecd2f2
GH-73991: Use same signature for `shutil._rmtree_[un]safe()`. (#120517)

Preparatory work for moving `_rmtree_unsafe()` and `_rmtree_safe_fd()` to
`pathlib._os` so that they can be used from both `shutil` and `pathlib`.

Move implementation-specific setup from `rmtree()` into the safe/unsafe
functions, and give them the same signature `(path, dir_fd, onexc)`.

In the tests, mock `os.open` rather than `_rmtree_safe_fd()` to ensure the
FD-based walk is used, and replace a couple references to
`shutil._use_fd_functions` with `shutil.rmtree.avoids_symlink_attacks`
(which has the same value).

No change of behaviour.
Lib/shutil.py
Lib/test/test_shutil.py