From 6aa1ef313cf1df4687cbef76ad4b2337cf692ba7 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 23 Nov 2024 14:47:08 -0500 Subject: [PATCH] Doc: C API: Fix `Py_NewInterpreterFromConfig` example code (GH-126667) (cherry picked from commit e3038e976b25a58f512d8c7083a752c89436eb0d) Co-authored-by: Richard Hansen --- Doc/c-api/init.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index bec075038f06e0..aacbab0b3532e7 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -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