mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
GH-105840: Fix assertion failures when specializing calls with too many __defaults__ (GH-105847)
This commit is contained in:
parent
b356a4749a
commit
2beab5bdef
3 changed files with 33 additions and 2 deletions
|
@ -1647,9 +1647,9 @@ specialize_py_call(PyFunctionObject *func, _Py_CODEUNIT *instr, int nargs,
|
|||
}
|
||||
int argcount = code->co_argcount;
|
||||
int defcount = func->func_defaults == NULL ? 0 : (int)PyTuple_GET_SIZE(func->func_defaults);
|
||||
assert(defcount <= argcount);
|
||||
int min_args = argcount-defcount;
|
||||
if (nargs > argcount || nargs < min_args) {
|
||||
// GH-105840: min_args is negative when somebody sets too many __defaults__!
|
||||
if (min_args < 0 || nargs > argcount || nargs < min_args) {
|
||||
SPECIALIZATION_FAIL(CALL, SPEC_FAIL_WRONG_NUMBER_ARGUMENTS);
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue