summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-02-03 17:08:03 (GMT)
committerBrett Cannon <brett@python.org>2012-02-03 17:08:03 (GMT)
commitb6855683cc808054349af9945653f6c626c3c8da (patch)
treeef7c4d7c338d0d5127a9d7a0255b95d6244fed92 /Modules/_testcapimodule.c
parent61c4e10035aa1ffe5c0d78e5b918b8df4e20a263 (diff)
downloadcpython-b6855683cc808054349af9945653f6c626c3c8da.zip
cpython-b6855683cc808054349af9945653f6c626c3c8da.tar.gz
cpython-b6855683cc808054349af9945653f6c626c3c8da.tar.bz2
Check for errors in creating sub-interpreters when testing the C API.
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index b00ac20..bcb3a0f 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -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);