This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Caught infinite recursion resets the trace function
Type: behavior Stage: resolved
Components: Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Tracing disabled when a recursion error is triggered (even if properly handled)
View: 10933
Assigned To: Nosy List: belopolsky
Priority: normal Keywords:

Created on 2018-06-12 22:24 by belopolsky, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg319409 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2018-06-12 22:24
Consider the following code:

import sys

def trace(frame, event, arg):
    pass

def f():
    f()
sys.settrace(trace)
print(sys.gettrace())
try:
    f()
except RuntimeError:
    pass
print(sys.gettrace())

When I run it, I get

<function trace at 0x108865158>
None

Apparently, the infinite recursion somehow resets the trace function.  This interferes with the coverage tools.
msg319410 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2018-06-12 22:29
It looks like this has been known for quite some time.  See issue10933.
History
Date User Action Args
2022-04-11 14:59:01adminsetgithub: 78030
2018-06-12 22:30:31belopolskysetstatus: open -> closed
stage: needs patch -> resolved
2018-06-12 22:30:19belopolskysetsuperseder: Tracing disabled when a recursion error is triggered (even if properly handled)
resolution: duplicate
2018-06-12 22:29:40belopolskysetmessages: + msg319410
2018-06-12 22:24:35belopolskycreate