[New-bugs-announce] [issue40870] Custom AST can crash Python (debug build)

Batuhan Taskaya report at bugs.python.org
Fri Jun 5 05:46:27 EDT 2020

New submission from Batuhan Taskaya <isidentical at gmail.com>:

import ast
t = ast.fix_missing_locations(ast.Expression(ast.Name("True", ast.Load())))
compile(t, "<t>", "eval")

compilation of this AST can crash the interpreter for 3.8+

test_constant_as_name (test.test_ast.AST_Tests) ... python: Python/compile.c:3559: compiler_nameop: Assertion `!_PyUnicode_EqualToASCIIString(name, "None") && !_PyUnicode_EqualToASCIIString(name, "True") && !_PyUnicode_EqualToASCIIString(name, "False")' failed.
Fatal Python error: Aborted

I've encountered this while running test suite of 'pytest' with the current master, so I guess there are some usages related this out there. IMHO we should validate this on the PyAST_Validate step to prevent this kind of crashes.

messages: 370753
nosy: BTaskaya
priority: normal
severity: normal
status: open
title: Custom AST can crash Python (debug build)

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list