Xavier de Gaye added the comment:

Antoine asked in PR 1981:
> Did you verify the removed code here wasn't needed anymore?

Just checked that crasher infinite_rec_2.py (removed by 1e534b5) does not crash 
with PR 1981. The other crashers listed at 1e534b5 are not valid Python 3.7 
code.  Does anyone know how to translate them into Python 3.7 ?

With PR 1981 infinite recursion does not occur in PyErr_NormalizeException() 
when the tstate->overflowed flag is false upon entering this function and:
    * either (obviously) the normalizing of this exception does not fail
    * or the normalizing of this exception fails with an exception whose 
normalization won't fail (for example a RecursionError).

Removing the PyExc_RecursionErrorInst singleton decreases the cases covered by 
the recursion checks because the test made upon using PyExc_RecursionErrorInst 
(in the 'finally' label of PyErr_NormalizeException()) has the side effect of 
adding another recursion check to the normal recursion machinery of 
_Py_CheckRecursiveCall().  Those are corner cases though, such as for example 
the following case that will abort instead now with PR 1981 [1]:
    * tstate->overflowed has been set to true outside 
PyErr_NormalizeException() and the corresponding RecursionError has been 
discarded
    * PyErr_NormalizeException() attempts normalizing a python exception that 
raises a python exception that raises ... (and so on indefinitely)
IMO it is ok to abort in such cases. As Brett wrote 9 years ago in 
https://mail.python.org/pipermail/python-dev/2008-August/082107.html:
    "I have always viewed the check as a bonus sanity check, but not something 
to heavily rely upon."
One can also note that this other recursion check added with the use of 
PyExc_RecursionErrorInst does not respect the tstate->overflowed flag so that 
it adds another level of complexity to the recursion machinery.

[1] But with PR 1981, a RecursionError is raised when replacing MyException in 
test_recursion_normalizing_exception() at Lib/test/test_exceptions.py with:

      class MyException(Exception):
          def __init__(self):
              raise MyException

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22898>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to