Skip to content

Assertion failure when specializing functions with too many __defaults__ #105840

Closed
@brandtbucher

Description

@brandtbucher

When specializing some Python calls, we assert that we don't have more defaults than we have arguments. This isn't always true, though:

>>> def f():
...     pass
... 
>>> f.__defaults__ = (None,)
>>> for _ in range(2):
...     f()
... 
python: Python/specialize.c:1650: specialize_py_call: Assertion `defcount <= argcount' failed.
Aborted

Linked PRs

Metadata

Metadata

Assignees

Labels

3.11only security fixes3.12only security fixes3.13bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)triagedThe issue has been accepted as valid by a triager.type-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