mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
Check for errors in creating sub-interpreters when testing the C API.
This commit is contained in:
parent
61c4e10035
commit
b6855683cc
1 changed files with 8 additions and 0 deletions
|
|
@ -2396,6 +2396,14 @@ run_in_subinterp(PyObject *self, PyObject *args)
|
|||
PyThreadState_Swap(NULL);
|
||||
|
||||
substate = Py_NewInterpreter();
|
||||
if (substate == NULL) {
|
||||
/* Since no new thread state was created, there is no exception to
|
||||
propagate; raise a fresh one after swapping in the old thread
|
||||
state. */
|
||||
PyThreadState_Swap(mainstate);
|
||||
PyErr_SetString(PyExc_RuntimeError, "sub-interpreter creation failed");
|
||||
return NULL;
|
||||
}
|
||||
r = PyRun_SimpleString(code);
|
||||
Py_EndInterpreter(substate);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue