@@ -25,7 +25,7 @@ Initializing and finalizing the interpreter
2525 triple: module; search; path
2626 single: PySys_SetArgv()
2727 single: PySys_SetArgvEx()
28- single: Py_Finalize ()
28+ single: Py_FinalizeEx ()
2929
3030 Initialize the Python interpreter. In an application embedding Python, this
3131 should be called before using any other Python/C API functions; with the
@@ -34,7 +34,7 @@ Initializing and finalizing the interpreter
3434 modules :mod: `builtins `, :mod: `__main__ ` and :mod: `sys `. It also initializes
3535 the module search path (``sys.path ``). It does not set ``sys.argv ``; use
3636 :c:func: `PySys_SetArgvEx ` for that. This is a no-op when called for a second time
37- (without calling :c:func: `Py_Finalize ` first). There is no return value; it is a
37+ (without calling :c:func: `Py_FinalizeEx ` first). There is no return value; it is a
3838 fatal error if the initialization fails.
3939
4040
@@ -48,19 +48,20 @@ Initializing and finalizing the interpreter
4848.. c:function:: int Py_IsInitialized()
4949
5050 Return true (nonzero) when the Python interpreter has been initialized, false
51- (zero) if not. After :c:func:`Py_Finalize ` is called, this returns false until
51+ (zero) if not. After :c:func:`Py_FinalizeEx ` is called, this returns false until
5252 :c:func:`Py_Initialize` is called again.
5353
5454
55- .. c:function:: void Py_Finalize ()
55+ .. c:function:: int Py_FinalizeEx ()
5656
5757 Undo all initializations made by :c:func:`Py_Initialize` and subsequent use of
5858 Python/C API functions, and destroy all sub-interpreters (see
5959 :c:func: `Py_NewInterpreter ` below) that were created and not yet destroyed since
6060 the last call to :c:func:`Py_Initialize`. Ideally, this frees all memory
6161 allocated by the Python interpreter. This is a no-op when called for a second
62- time (without calling :c:func: `Py_Initialize ` again first). There is no return
63- value; errors during finalization are ignored.
62+ time (without calling :c:func: `Py_Initialize ` again first). Normally the
63+ return value is 0. If there were errors during finalization
64+ (flushing buffered data), -1 is returned.
6465
6566 This function is provided for a number of reasons. An embedding application
6667 might want to restart Python without having to restart the application itself.
@@ -79,7 +80,15 @@ Initializing and finalizing the interpreter
7980 freed. Some memory allocated by extension modules may not be freed. Some
8081 extensions may not work properly if their initialization routine is called more
8182 than once; this can happen if an application calls :c:func:`Py_Initialize` and
82- :c:func: `Py_Finalize ` more than once.
83+ :c:func: `Py_FinalizeEx ` more than once.
84+
85+ .. versionadded :: 3.6
86+
87+
88+ .. c :function :: void Py_Finalize ()
89+
90+ This is a backwards-compatible version of :c:func:`Py_FinalizeEx` that
91+ disregards the return value.
8392
8493
8594Process-wide parameters
@@ -107,7 +116,7 @@ Process-wide parameters
107116 Note that :data:`sys.stderr` always uses the "backslashreplace" error
108117 handler, regardless of this (or any other) setting.
109118
110- If :c:func:`Py_Finalize ` is called, this function will need to be called
119+ If :c:func:`Py_FinalizeEx ` is called, this function will need to be called
111120 again in order to affect subsequent calls to :c:func:`Py_Initialize`.
112121
113122 Returns 0 if successful, a nonzero value on error (e.g. calling after the
@@ -918,7 +927,7 @@ using the following functions:
918927 entry.)
919928
920929 .. index::
921- single: Py_Finalize ()
930+ single: Py_FinalizeEx ()
922931 single: Py_Initialize()
923932
924933 Extension modules are shared between (sub-)interpreters as follows: the first
@@ -928,22 +937,22 @@ using the following functions:
928937 and filled with the contents of this copy; the extension' s ``init`` function is
929938 not called. Note that this is different from what happens when an extension is
930939 imported after the interpreter has been completely re-initialized by calling
931- :c:func:`Py_Finalize ` and :c:func:`Py_Initialize`; in that case, the extension' s
940+ :c:func:`Py_FinalizeEx ` and :c:func:`Py_Initialize`; in that case, the extension' s
932941 ``initmodule `` function *is * called again.
933942
934943 .. index :: single: close() (in module os)
935944
936945
937946.. c :function :: void Py_EndInterpreter (PyThreadState *tstate)
938947
939- .. index :: single: Py_Finalize ()
948+ .. index :: single: Py_FinalizeEx ()
940949
941950 Destroy the (sub-)interpreter represented by the given thread state. The given
942951 thread state must be the current thread state. See the discussion of thread
943952 states below. When the call returns, the current thread state is *NULL*. All
944953 thread states associated with this interpreter are destroyed. (The global
945954 interpreter lock must be held before calling this function and is still held
946- when it returns.) :c:func:`Py_Finalize ` will destroy all sub-interpreters that
955+ when it returns.) :c:func:`Py_FinalizeEx ` will destroy all sub-interpreters that
947956 haven't been explicitly destroyed at that point.
948957
949958
0 commit comments