Skip to content

_PyPegen_add_type_comment_to_arg can fail in _PyPegen_name_default_pair #148157

@StanFromIreland

Description

@StanFromIreland

Crash report

What happened?

>>> import _testcapi
>>> _testcapi.Py_CompileStringExFlags(b"def a(f=8,#type: \x80\n\x80", "<test>", 256, 0x0800 | 0x1000)
python: Objects/typeobject.c:2440: type_call: Assertion `!_PyErr_Occurred(tstate)' failed.
Aborted                    (core dumped) ./python

In _PyPegen_name_default_pair, we call:

a->arg = _PyPegen_add_type_comment_to_arg(p, arg, tc);

but don't check if it failed (and returned NULL).

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Output from running 'python -VV' on the command line:

No response

Linked PRs

Metadata

Metadata

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)topic-parsertype-crashA hard crash of the interpreter, possibly with a core dump

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions