Skip to content

_PyPegen_add_type_comment_to_arg can fail in _PyPegen_name_default_pair #148157

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

Activity

  1. added a commit that references this issue on Apr 6, 2026
  2. added 2 commits that reference this issue on Apr 6, 2026
  3. added a commit that references this issue on Apr 6, 2026
  4. added a commit that references this issue on Apr 6, 2026
  5. added a commit that references this issue on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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