[Python-checkins] r71058 - in python/trunk: Misc/NEWS Python/errors.c
georg.brandl
python-checkins at python.org
Thu Apr 2 20:09:05 CEST 2009
Author: georg.brandl
Date: Thu Apr 2 20:09:04 2009
New Revision: 71058
Log:
PyErr_NormalizeException may not set an error, so convert the PyErr_SetObject
call on hitting the recursion limit into just assigning it to the arguments provided.
Modified:
python/trunk/Misc/NEWS
python/trunk/Python/errors.c
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Thu Apr 2 20:09:04 2009
@@ -12,6 +12,9 @@
Core and Builtins
-----------------
+- Fix a problem in PyErr_NormalizeException that leads to "undetected errors"
+ when hitting the recursion limit under certain circumstances.
+
- Issue #1665206: Remove the last eager import in _warnings.c and make it lazy.
- Issue #4865: On MacOSX /Library/Python/2.7/site-packages is added to
Modified: python/trunk/Python/errors.c
==============================================================================
--- python/trunk/Python/errors.c (original)
+++ python/trunk/Python/errors.c Thu Apr 2 20:09:04 2009
@@ -225,7 +225,15 @@
tstate = PyThreadState_GET();
if (++tstate->recursion_depth > Py_GetRecursionLimit()) {
--tstate->recursion_depth;
- PyErr_SetObject(PyExc_RuntimeError, PyExc_RecursionErrorInst);
+ /* throw away the old exception... */
+ Py_DECREF(*exc);
+ Py_DECREF(*val);
+ /* ... and use the recursion error instead */
+ *exc = PyExc_RuntimeError;
+ *val = PyExc_RecursionErrorInst;
+ Py_INCREF(*exc);
+ Py_INCREF(*val);
+ /* just keeping the old traceback */
return;
}
PyErr_NormalizeException(exc, val, tb);
More information about the Python-checkins
mailing list