[issue36474] RecursionError resets trace function set via sys.settrace
daniel hahler
report at bugs.python.org
Fri Mar 29 15:11:18 EDT 2019
New submission from daniel hahler <python-bugs at 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 <report at bugs.python.org>
<https://bugs.python.org/issue36474>
_______________________________________
More information about the Python-bugs-list
mailing list