]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-120838: Add a Note in the Docs About Expectations for Py_Finalize() (gh-120839)
authorEric Snow <ericsnowcurrently@gmail.com>
Fri, 21 Jun 2024 19:05:53 +0000 (13:05 -0600)
committerGitHub <noreply@github.com>
Fri, 21 Jun 2024 19:05:53 +0000 (13:05 -0600)
Doc/c-api/init.rst

index 58c79031de5320784b785d4f0449382083ec2f00..6b454131d8707579ccacdf7871911eb867bc8573 100644 (file)
@@ -396,9 +396,16 @@ Initializing and finalizing the interpreter
    :c:func:`Py_NewInterpreter` below) that were created and not yet destroyed since
    the last call to :c:func:`Py_Initialize`.  Ideally, this frees all memory
    allocated by the Python interpreter.  This is a no-op when called for a second
-   time (without calling :c:func:`Py_Initialize` again first).  Normally the
-   return value is ``0``.  If there were errors during finalization
-   (flushing buffered data), ``-1`` is returned.
+   time (without calling :c:func:`Py_Initialize` again first).
+
+   Since this is the reverse of :c:func:`Py_Initialize`, it should be called
+   in the same thread with the same interpreter active.  That means
+   the main thread and the main interpreter.
+   This should never be called while :c:func:`Py_RunMain` is running.
+
+   Normally the return value is ``0``.
+   If there were errors during finalization (flushing buffered data),
+   ``-1`` is returned.
 
    This function is provided for a number of reasons.  An embedding application
    might want to restart Python without having to restart the application itself.