]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] Doc: C API: Fix `Py_NewInterpreterFromConfig` example code (GH-126667) (#127202)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 23 Nov 2024 19:55:55 +0000 (20:55 +0100)
committerGitHub <noreply@github.com>
Sat, 23 Nov 2024 19:55:55 +0000 (19:55 +0000)
Doc: C API: Fix `Py_NewInterpreterFromConfig` example code (GH-126667)
(cherry picked from commit e3038e976b25a58f512d8c7083a752c89436eb0d)

Co-authored-by: Richard Hansen <rhansen@rhansen.org>
Doc/c-api/init.rst

index bec075038f06e0d8d03c68f868f59ef4757e7d93..aacbab0b3532e7a5d08e89818c585a4f2ce6979f 100644 (file)
@@ -1644,7 +1644,11 @@ function. You can create and destroy them using the following functions:
           .check_multi_interp_extensions = 1,
           .gil = PyInterpreterConfig_OWN_GIL,
       };
-      PyThreadState *tstate = Py_NewInterpreterFromConfig(&config);
+      PyThreadState *tstate = NULL;
+      PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);
+      if (PyStatus_Exception(status)) {
+          Py_ExitStatusException(status);
+      }
 
    Note that the config is used only briefly and does not get modified.
    During initialization the config's values are converted into various