Mercurial > cpython-lru_cache-weakref
comparison Python/errors.c @ 43276:3bc3f12cae28 legacy-trunk
Fix a crasher where Python code managed to infinitely recurse in C code without
ever going back out to Python code in PyObject_Call(). Required introducing a
static RuntimeError instance so that normalizing an exception there is no
reliance on a recursive call that would put the exception system over the
recursion check itself.
| author | Brett Cannon <bcannon@gmail.com> |
|---|---|
| date | Fri, 07 Sep 2007 04:18:30 +0000 |
| parents | c83acfb1a632 |
| children | 0cbe94bea2c7 |
comparison
equal
deleted
inserted
replaced
| 43275:57eabb051cfd | 43276:3bc3f12cae28 |
|---|---|
| 130 { | 130 { |
| 131 PyObject *type = *exc; | 131 PyObject *type = *exc; |
| 132 PyObject *value = *val; | 132 PyObject *value = *val; |
| 133 PyObject *inclass = NULL; | 133 PyObject *inclass = NULL; |
| 134 PyObject *initial_tb = NULL; | 134 PyObject *initial_tb = NULL; |
| 135 PyThreadState *tstate = NULL; | |
| 135 | 136 |
| 136 if (type == NULL) { | 137 if (type == NULL) { |
| 137 /* There was no exception, so nothing to do. */ | 138 /* There was no exception, so nothing to do. */ |
| 138 return; | 139 return; |
| 139 } | 140 } |
| 205 *tb = initial_tb; | 206 *tb = initial_tb; |
| 206 else | 207 else |
| 207 Py_DECREF(initial_tb); | 208 Py_DECREF(initial_tb); |
| 208 } | 209 } |
| 209 /* normalize recursively */ | 210 /* normalize recursively */ |
| 211 tstate = PyThreadState_GET(); | |
| 212 if (++tstate->recursion_depth > Py_GetRecursionLimit()) { | |
| 213 --tstate->recursion_depth; | |
| 214 PyErr_SetObject(PyExc_RuntimeError, PyExc_RecursionErrorInst); | |
| 215 return; | |
| 216 } | |
| 210 PyErr_NormalizeException(exc, val, tb); | 217 PyErr_NormalizeException(exc, val, tb); |
| 218 --tstate->recursion_depth; | |
| 211 } | 219 } |
| 212 | 220 |
| 213 | 221 |
| 214 void | 222 void |
| 215 PyErr_Fetch(PyObject **p_type, PyObject **p_value, PyObject **p_traceback) | 223 PyErr_Fetch(PyObject **p_type, PyObject **p_value, PyObject **p_traceback) |
