bpo-46245: Add optional parameter dir_fd in shutil.rmtree() (GH-30365)

This commit is contained in:
Serhiy Storchaka 2022-03-09 14:29:33 +02:00 committed by GitHub
parent 5eb03b1b51
commit 02fbaf4887
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 7 deletions

View file

@ -286,7 +286,7 @@ Directory and files operations
.. versionadded:: 3.8
The *dirs_exist_ok* parameter.
.. function:: rmtree(path, ignore_errors=False, onerror=None)
.. function:: rmtree(path, ignore_errors=False, onerror=None, *, dir_fd=None)
.. index:: single: directory; deleting
@ -296,6 +296,9 @@ Directory and files operations
handled by calling a handler specified by *onerror* or, if that is omitted,
they raise an exception.
This function can support :ref:`paths relative to directory descriptors
<dir_fd>`.
.. note::
On platforms that support the necessary fd-based functions a symlink
@ -315,7 +318,7 @@ Directory and files operations
*excinfo*, will be the exception information returned by
:func:`sys.exc_info`. Exceptions raised by *onerror* will not be caught.
.. audit-event:: shutil.rmtree path shutil.rmtree
.. audit-event:: shutil.rmtree path,dir_fd shutil.rmtree
.. versionchanged:: 3.3
Added a symlink attack resistant version that is used automatically
@ -325,6 +328,9 @@ Directory and files operations
On Windows, will no longer delete the contents of a directory junction
before removing the junction.
.. versionchanged:: 3.11
The *dir_fd* parameter.
.. attribute:: rmtree.avoids_symlink_attacks
Indicates whether the current platform and implementation provides a