The generated code in Python-ast.c is missing error checks following the construction of C-level alias, arg, comprehension, keyword, match_item, and withitem nodes from their Python object counterparts. This means it's possible to crash the interpreter by attempting to compile an AST where a required member of these nodes is replaced with None:
>>> import ast
>>> tree = ast.parse("""
... match ...:
... case THIS:
... ...
... """)
>>> tree.body[0].cases[0].pattern = None
>>> compile(tree, "<crash>", "exec")
Segmentation fault
I'll have a PR up in a minute with the one-line fix.
Linked PRs
The generated code in
Python-ast.cis missing error checks following the construction of C-levelalias,arg,comprehension,keyword,match_item, andwithitemnodes from their Python object counterparts. This means it's possible to crash the interpreter by attempting to compile an AST where a required member of these nodes is replaced withNone:I'll have a PR up in a minute with the one-line fix.
Linked PRs
obj2ast_*converters #105589