Skip to content

Commit 6d2821c

Browse files
[3.12] Doc: C API: Fix Py_NewInterpreterFromConfig example code (GH-126667) (#127202)
Doc: C API: Fix `Py_NewInterpreterFromConfig` example code (GH-126667) (cherry picked from commit e3038e9) Co-authored-by: Richard Hansen <[email protected]>
1 parent f1e7424 commit 6d2821c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Doc/c-api/init.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,11 @@ function. You can create and destroy them using the following functions:
16441644
.check_multi_interp_extensions = 1,
16451645
.gil = PyInterpreterConfig_OWN_GIL,
16461646
};
1647-
PyThreadState *tstate = Py_NewInterpreterFromConfig(&config);
1647+
PyThreadState *tstate = NULL;
1648+
PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);
1649+
if (PyStatus_Exception(status)) {
1650+
Py_ExitStatusException(status);
1651+
}
16481652
16491653
Note that the config is used only briefly and does not get modified.
16501654
During initialization the config's values are converted into various

0 commit comments

Comments
 (0)