]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Doc: C API: Fix `Py_NewInterpreterFromConfig` example code (#126667)
authorRichard Hansen <rhansen@rhansen.org>
Sat, 23 Nov 2024 19:47:08 +0000 (14:47 -0500)
committerGitHub <noreply@github.com>
Sat, 23 Nov 2024 19:47:08 +0000 (21:47 +0200)
Doc/c-api/init.rst

index 24d876d1f35506576b1e309891396054d3cb0ea3..970084ce91ab69499a9efa40ab7d24ab833b6474 100644 (file)
@@ -1738,7 +1738,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