From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 23 Nov 2024 19:54:12 +0000 (+0100) Subject: [3.13] Doc: C API: Fix `Py_NewInterpreterFromConfig` example code (GH-126667) (#127201) X-Git-Tag: v3.13.1~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1a241ef4cb575e221a03e986a5e9f811873b411;p=thirdparty%2FPython%2Fcpython.git [3.13] Doc: C API: Fix `Py_NewInterpreterFromConfig` example code (GH-126667) (#127201) Doc: C API: Fix `Py_NewInterpreterFromConfig` example code (GH-126667) (cherry picked from commit e3038e976b25a58f512d8c7083a752c89436eb0d) Co-authored-by: Richard Hansen --- diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 48e24e64cd08..41093bf852b2 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -1688,7 +1688,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