Author xdegaye
Recipients emptysquare, pitrou, serhiy.storchaka, vstinner, xdegaye
Date 2017-06-10.10:08:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1497089323.83.0.768042035074.issue22898@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2017-06-10 10:08:43xdegayesetrecipients: + xdegaye, pitrou, vstinner, serhiy.storchaka, emptysquare
2017-06-10 10:08:43xdegayesetmessageid: <1497089323.83.0.768042035074.issue22898@psf.upfronthosting.co.za>
2017-06-10 10:08:43xdegayelinkissue22898 messages
2017-06-10 10:08:42xdegayecreate