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: RecursionError resets trace function set via sys.settrace
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.9
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: blueyed, gphemsley
Priority: normal Keywords:

Created on 2019-03-29 19:11 by blueyed, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg339135 - (view) Author: daniel hahler (blueyed) * Date: 2019-03-29 19:11
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

```
msg339136 - (view) Author: daniel hahler (blueyed) * Date: 2019-03-29 19:13
Discovered via / relevant for coverage's PyTracer: https://github.com/nedbat/coveragepy/issues/787.
msg342393 - (view) Author: daniel hahler (blueyed) * Date: 2019-05-13 22:11
Duplicate of https://bugs.python.org/issue10933.
History
Date User Action Args
2022-04-11 14:59:13adminsetgithub: 80655
2019-05-18 01:27:13gphemsleysetnosy: + gphemsley
2019-05-13 22:11:19blueyedsetstatus: open -> closed
resolution: duplicate
messages: + msg342393

stage: resolved
2019-03-29 19:13:47blueyedsetmessages: + msg339136
2019-03-29 19:11:18blueyedcreate