diff options
author | CAM Gerlach <CAM.Gerlach@Gerlach.CAM> | 2021-03-14 18:06:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-14 18:06:56 (GMT) |
commit | bd2fa3c416ffe6107b500a2180fa1764645c0a61 (patch) | |
tree | 44a53d55e02511cb6f6a1641c678c1b179f87863 /Doc/library/tempfile.rst | |
parent | d48848c83e0f3e41b65c8f741f3fb6dbce5b9c29 (diff) | |
download | cpython-bd2fa3c416ffe6107b500a2180fa1764645c0a61.zip cpython-bd2fa3c416ffe6107b500a2180fa1764645c0a61.tar.gz cpython-bd2fa3c416ffe6107b500a2180fa1764645c0a61.tar.bz2 |
bpo-29982: Add "ignore_cleanup_errors" param to tempfile.TemporaryDirectory() (GH-24793)
Diffstat (limited to 'Doc/library/tempfile.rst')
-rw-r--r-- | Doc/library/tempfile.rst | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst index 2b8a35e..f843191 100644 --- a/Doc/library/tempfile.rst +++ b/Doc/library/tempfile.rst @@ -118,12 +118,12 @@ The module defines the following user-callable items: Added *errors* parameter. -.. function:: TemporaryDirectory(suffix=None, prefix=None, dir=None) +.. function:: TemporaryDirectory(suffix=None, prefix=None, dir=None, ignore_cleanup_errors=False) This function securely creates a temporary directory using the same rules as :func:`mkdtemp`. The resulting object can be used as a context manager (see :ref:`tempfile-examples`). On completion of the context or destruction - of the temporary directory object the newly created temporary directory + of the temporary directory object, the newly created temporary directory and all its contents are removed from the filesystem. The directory name can be retrieved from the :attr:`name` attribute of the @@ -132,12 +132,21 @@ The module defines the following user-callable items: the :keyword:`with` statement, if there is one. The directory can be explicitly cleaned up by calling the - :func:`cleanup` method. + :func:`cleanup` method. If *ignore_cleanup_errors* is true, any unhandled + exceptions during explicit or implicit cleanup (such as a + :exc:`PermissionError` removing open files on Windows) will be ignored, + and the remaining removable items deleted on a "best-effort" basis. + Otherwise, errors will be raised in whatever context cleanup occurs + (the :func:`cleanup` call, exiting the context manager, when the object + is garbage-collected or during interpreter shutdown). .. audit-event:: tempfile.mkdtemp fullpath tempfile.TemporaryDirectory .. versionadded:: 3.2 + .. versionchanged:: 3.10 + Added *ignore_cleanup_errors* parameter. + .. function:: mkstemp(suffix=None, prefix=None, dir=None, text=False) |