diff options
author | Jeffrey Yasskin <jyasskin@gmail.com> | 2010-05-13 18:31:05 (GMT) |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@gmail.com> | 2010-05-13 18:31:05 (GMT) |
commit | 8e0bdfd1d473ddffaf3501768678f8a970019da8 (patch) | |
tree | df31716c768c6512c72f40819f0cc752c7e742f4 /Modules/_testcapimodule.c | |
parent | f55621115cb2b73f60e7396cbade18a89a80d989 (diff) | |
download | cpython-8e0bdfd1d473ddffaf3501768678f8a970019da8.zip cpython-8e0bdfd1d473ddffaf3501768678f8a970019da8.tar.gz cpython-8e0bdfd1d473ddffaf3501768678f8a970019da8.tar.bz2 |
Make PyErr_Occurred return NULL if there is no current thread. Previously it
would Py_FatalError, which called PyErr_Occurred, resulting in a semi-infinite
recursion.
Fixes issue 3605.
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 2868014..ba81f71 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -2005,6 +2005,17 @@ make_exception_with_doc(PyObject *self, PyObject *args, PyObject *kwargs) return PyErr_NewExceptionWithDoc(name, doc, base, dict); } +/* Test that the fatal error from not having a current thread doesn't + cause an infinite loop. Run via Lib/test/test_capi.py */ +static PyObject * +crash_no_current_thread(PyObject *self) +{ + Py_BEGIN_ALLOW_THREADS + PyErr_SetString(PyExc_SystemError, "bork bork bork"); + Py_END_ALLOW_THREADS + return NULL; +} + static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, {"raise_memoryerror", (PyCFunction)raise_memoryerror, METH_NOARGS}, @@ -2069,6 +2080,7 @@ static PyMethodDef TestMethods[] = { {"code_newempty", code_newempty, METH_VARARGS}, {"make_exception_with_doc", (PyCFunction)make_exception_with_doc, METH_VARARGS | METH_KEYWORDS}, + {"crash_no_current_thread", (PyCFunction)crash_no_current_thread, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; |