Mercurial > cpython-lru_cache-weakref
comparison Python/errors.c @ 61555:1698c55b2af9
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.
| author | Jeffrey Yasskin <jyasskin@gmail.com> |
|---|---|
| date | Thu, 13 May 2010 18:31:05 +0000 |
| parents | cab14be0ada1 |
| children | 600c23127207 |
comparison
equal
deleted
inserted
replaced
| 61551:431a151e102d | 61555:1698c55b2af9 |
|---|---|
| 128 | 128 |
| 129 | 129 |
| 130 PyObject * | 130 PyObject * |
| 131 PyErr_Occurred(void) | 131 PyErr_Occurred(void) |
| 132 { | 132 { |
| 133 PyThreadState *tstate = PyThreadState_GET(); | 133 /* If there is no thread state, PyThreadState_GET calls |
| 134 | 134 Py_FatalError, which calls PyErr_Occurred. To avoid the |
| 135 return tstate->curexc_type; | 135 resulting infinite loop, we inline PyThreadState_GET here and |
| 136 treat no thread as no error. */ | |
| 137 PyThreadState *tstate = | |
| 138 ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current)); | |
| 139 | |
| 140 return tstate == NULL ? NULL : tstate->curexc_type; | |
| 136 } | 141 } |
| 137 | 142 |
| 138 | 143 |
| 139 int | 144 int |
| 140 PyErr_GivenExceptionMatches(PyObject *err, PyObject *exc) | 145 PyErr_GivenExceptionMatches(PyObject *err, PyObject *exc) |
