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.

Title: RecursionError depth exceptions break pdb's interactive tracing.
Type: crash Stage:
Components: Interpreter Core Versions: Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: behindthebrain, iritkatriel, jack__d
Priority: normal Keywords:

Created on 2021-03-19 02:44 by behindthebrain, last changed 2022-04-11 14:59 by admin.

File name Uploaded Description Edit behindthebrain, 2021-03-19 02:44 The simplified code to reproduce the bug.
Messages (3)
msg389051 - (view) Author: behind thebrain (behindthebrain) Date: 2021-03-19 02:44
If pdb encounters most exception types, it handles them as would be expected. However, if pdb encounters a RecursionError: maximum recursion depth exceeded while calling a Python object, then it will continue to execute the code accurately, but the debugger itself will no longer interactively wait for user input, but instead, just speed through the rest of execution. The code below reproduces the error on python 3.7, 3.8, and 3.9.

import sys
import inspect


def except_works() -> None:
    raise Exception

except Exception as e:
    print("Exception was:", e)

def funcy(depth: int) -> None:
    print(f"Stack depth is:{len(inspect.stack())}")
    if depth == 0:
    funcy(depth - 1)

except Exception as e:
    print("Exception was:", e)

print("This executes without the debugger navigating to it.")
msg398439 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-07-28 22:56
What do you mean by "it handles them as would be expected"? What is expected?

Ideally, can you provide a script with another exception type that shows it?  Specify also how you are running the script and what output you get. 

(I tried to modify your script but didn't see different behavior with other exceptions).
msg398442 - (view) Author: Jack DeVries (jack__d) * Date: 2021-07-28 23:23
@behindthebrain, I noticed that this script behaves weirdly when I try to set breakpoints at various places. However, the problem goes away when I raise the recursion limit. Things in python will not work right if you set the recursion limit to a low value. For example, this hello, world program does not run at a recursion depth of four::

    import sys

    print('hello, world')
Date User Action Args
2022-04-11 14:59:43adminsetgithub: 87714
2021-07-28 23:23:10jack__dsetnosy: + jack__d
messages: + msg398442
2021-07-28 22:56:15iritkatrielsetnosy: + iritkatriel
messages: + msg398439
2021-03-19 02:46:43behindthebrainsettype: crash
2021-03-19 02:44:55behindthebraincreate