Rémi Lapeyre <remi.lape...@henki.fr> added the comment:

I'm not sure issue35542. I think this happens because while logging the 
recursion limit is hit which calls 
https://github.com/python/cpython/blob/master/Python/ceval.c#L535-L539.

The RecursionError is then handled by 
https://github.com/python/cpython/blob/master/Lib/logging/__init__.py#L1000 and 
cleared.

On subsequent calls the exception is not set anymore because 
`tstate->overflowed` equals 1 so we exit early before setting the exception 
again at https://github.com/python/cpython/blob/master/Python/ceval.c#L531.

This goes on until the condition on 
https://github.com/python/cpython/blob/master/Python/ceval.c#L531 pass which 
abort the interpreter.

I think there is two ways to solve the issue, either handle RecursionError 
explicitly in the logging module so we don't clear it inadvertently as there is 
no way to recover from it anyway or check if the exception has been cleared at 
https://github.com/python/cpython/blob/master/Python/ceval.c#L531 and set it 
again.

Handling it explictly in the logging module would not help for code doing this 
elsewhere:

def rec():
    try:
        rec()
    except:
        rec()
rec()


I can submit a patch if you want.

----------
nosy: +remi.lapeyre
versions: +Python 3.7, Python 3.8

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

Reply via email to