[New-bugs-announce] [issue40403] pdb does not drop into debugger upon SyntaxError caused by ast.literal_eval

Kerrick Staley report at bugs.python.org
Sun Apr 26 23:07:36 EDT 2020


New submission from Kerrick Staley <kerrick at kerrickstaley.com>:

Summary:
When you call ast.literal_eval on a string that does not contain valid Python code, it raises a SyntaxError. This causes pdb to exit instead of stopping execution at the point that the SyntaxError was raised.

To reproduce:
1. Create a Python file foo.py with these contents:

    import ast
    ast.literal_eval('')

2. Run python -m pdb foo.py
3. Type 'c' and hit enter.

Expected behavior:
pdb drops into a shell in ast.py at the point where the SyntaxError occurred.

Actual behavior:
The program exits, and a SyntaxError traceback is displayed.

System configuration:
Python 3.8.2 on Arch Linux.

----------
components: Library (Lib)
messages: 367363
nosy: Kerrick Staley
priority: normal
severity: normal
status: open
title: pdb does not drop into debugger upon SyntaxError caused by ast.literal_eval
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40403>
_______________________________________


More information about the New-bugs-announce mailing list