From d3127cdf54a8520e4d6e412c5a509d60a53a0053 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Sun, 14 May 2023 12:07:03 +0100 Subject: [PATCH 1/6] gh-67056: document that registering/unregistering an atexit func from within an atexit func is undefined --- Doc/library/atexit.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/atexit.rst b/Doc/library/atexit.rst index f7f038107d11fe..613c6f414a816e 100644 --- a/Doc/library/atexit.rst +++ b/Doc/library/atexit.rst @@ -45,6 +45,9 @@ internal error is detected, or when :func:`os._exit` is called. This function returns *func*, which makes it possible to use it as a decorator. + The effect of calling :func:`register` from another registered cleanup + function is undefined. + .. function:: unregister(func) @@ -55,6 +58,8 @@ internal error is detected, or when :func:`os._exit` is called. comparisons (``==``) are used internally during unregistration, so function references do not need to have matching identities. + The effect of calling :func:`unregister` from a registered cleanup function + is undefined. .. seealso:: From ed682f6c981b820b9e98e480e8830debef5eb04b Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Sun, 14 May 2023 12:11:39 +0100 Subject: [PATCH 2/6] add news --- .../Documentation/2023-05-14-12-11-28.gh-issue-67056.nVC2Rf.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Documentation/2023-05-14-12-11-28.gh-issue-67056.nVC2Rf.rst diff --git a/Misc/NEWS.d/next/Documentation/2023-05-14-12-11-28.gh-issue-67056.nVC2Rf.rst b/Misc/NEWS.d/next/Documentation/2023-05-14-12-11-28.gh-issue-67056.nVC2Rf.rst new file mode 100644 index 00000000000000..f18177539854f1 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2023-05-14-12-11-28.gh-issue-67056.nVC2Rf.rst @@ -0,0 +1,2 @@ +Document that the efect of registering or unregistering an :mod:`atexit` +cleanup function from within a registered cleanup function is undefined. From 3c6901e66e7a2017624365382675a62b0531fe9b Mon Sep 17 00:00:00 2001 From: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Date: Sun, 14 May 2023 17:12:03 +0100 Subject: [PATCH 3/6] typo Co-authored-by: Kirill Podoprigora --- .../Documentation/2023-05-14-12-11-28.gh-issue-67056.nVC2Rf.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Documentation/2023-05-14-12-11-28.gh-issue-67056.nVC2Rf.rst b/Misc/NEWS.d/next/Documentation/2023-05-14-12-11-28.gh-issue-67056.nVC2Rf.rst index f18177539854f1..2c6ef17810723d 100644 --- a/Misc/NEWS.d/next/Documentation/2023-05-14-12-11-28.gh-issue-67056.nVC2Rf.rst +++ b/Misc/NEWS.d/next/Documentation/2023-05-14-12-11-28.gh-issue-67056.nVC2Rf.rst @@ -1,2 +1,2 @@ -Document that the efect of registering or unregistering an :mod:`atexit` +Document that the effect of registering or unregistering an :mod:`atexit` cleanup function from within a registered cleanup function is undefined. From e23c17ba03d8545ddadfccbe772a771d98b621dc Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Sun, 14 May 2023 22:35:12 +0100 Subject: [PATCH 4/6] Revert "gh-67056: document that registering/unregistering an atexit func from within an atexit func is undefined" This reverts commit d3127cdf54a8520e4d6e412c5a509d60a53a0053. --- Doc/library/atexit.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Doc/library/atexit.rst b/Doc/library/atexit.rst index 613c6f414a816e..f7f038107d11fe 100644 --- a/Doc/library/atexit.rst +++ b/Doc/library/atexit.rst @@ -45,9 +45,6 @@ internal error is detected, or when :func:`os._exit` is called. This function returns *func*, which makes it possible to use it as a decorator. - The effect of calling :func:`register` from another registered cleanup - function is undefined. - .. function:: unregister(func) @@ -58,8 +55,6 @@ internal error is detected, or when :func:`os._exit` is called. comparisons (``==``) are used internally during unregistration, so function references do not need to have matching identities. - The effect of calling :func:`unregister` from a registered cleanup function - is undefined. .. seealso:: From 09a26fdce75447c7234aac7770d0ec1741117634 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Sun, 14 May 2023 22:37:44 +0100 Subject: [PATCH 5/6] add comment at the top --- Doc/library/atexit.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Doc/library/atexit.rst b/Doc/library/atexit.rst index f7f038107d11fe..d7db7016288811 100644 --- a/Doc/library/atexit.rst +++ b/Doc/library/atexit.rst @@ -20,6 +20,9 @@ at interpreter termination time they will be run in the order ``C``, ``B``, program is killed by a signal not handled by Python, when a Python fatal internal error is detected, or when :func:`os._exit` is called. +**Note:** The effect of registering or unregistering functions from within +a cleanup function is underfined. + .. versionchanged:: 3.7 When used with C-API subinterpreters, registered functions are local to the interpreter they were registered in. From 0972d0aa9687c0974fb89faf5e00f1e6ea889906 Mon Sep 17 00:00:00 2001 From: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Date: Sun, 14 May 2023 22:39:03 +0100 Subject: [PATCH 6/6] typo --- Doc/library/atexit.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/atexit.rst b/Doc/library/atexit.rst index d7db7016288811..a2bd85b31c9a8d 100644 --- a/Doc/library/atexit.rst +++ b/Doc/library/atexit.rst @@ -21,7 +21,7 @@ program is killed by a signal not handled by Python, when a Python fatal internal error is detected, or when :func:`os._exit` is called. **Note:** The effect of registering or unregistering functions from within -a cleanup function is underfined. +a cleanup function is undefined. .. versionchanged:: 3.7 When used with C-API subinterpreters, registered functions