[Python-checkins] cpython: Check for errors in creating sub-interpreters when testing the C API.
brett.cannon
python-checkins at python.org
Fri Feb 3 18:08:40 CET 2012
http://hg.python.org/cpython/rev/404c0c345321
changeset: 74742:404c0c345321
parent: 74740:84be86af9161
user: Brett Cannon <brett at python.org>
date: Fri Feb 03 12:08:03 2012 -0500
summary:
Check for errors in creating sub-interpreters when testing the C API.
files:
Modules/_testcapimodule.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -2396,6 +2396,14 @@
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);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list