New submission from daniel hahler <python-b...@thequod.de>: A RecursionError causes the trace function set via `sys.settrace` to get removed/unset.
Given the following script: ``` import sys def trace(*args): print("trace", args) return trace sys.settrace(trace) def f(): f() print(sys.gettrace()) try: f() except Exception as exc: print(exc) print(sys.gettrace()) ``` Running it will output: ``` <function trace at 0x7f848594f6c0> trace (<frame at 0x7f84859a5d98, file 't-settrace-recursionerror.py', line 11, code f>, 'call', None) trace (<frame at 0x7f84859a5d98, file 't-settrace-recursionerror.py', line 12, code f>, 'line', None) trace (<frame at 0x7f84858f73a0, file 't-settrace-recursionerror.py', line 11, code f>, 'call', None) trace (<frame at 0x7f84858f73a0, file 't-settrace-recursionerror.py', line 12, code f>, 'line', None) … trace (<frame at 0x7f84857f0c80, file 't-settrace-recursionerror.py', line 11, code f>, 'call', None) trace (<frame at 0x7f84857f0c80, file 't-settrace-recursionerror.py', line 12, code f>, 'line', None) trace maximum recursion depth exceeded while getting the repr of an object None ``` ---------- components: Interpreter Core messages: 339135 nosy: blueyed priority: normal severity: normal status: open title: RecursionError resets trace function set via sys.settrace versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36474> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com