mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-37122: Make co->co_argcount represent the total number of positonal arguments in the code object (GH-13726)
This commit is contained in:
parent
059b9ea5ac
commit
cd74e66a8c
14 changed files with 74 additions and 88 deletions
|
@ -114,8 +114,9 @@ PyCode_New(int argcount, int posonlyargcount, int kwonlyargcount,
|
|||
Py_ssize_t i, n_cellvars, n_varnames, total_args;
|
||||
|
||||
/* Check argument types */
|
||||
if (argcount < 0 || posonlyargcount < 0 || kwonlyargcount < 0 ||
|
||||
nlocals < 0 || stacksize < 0 || flags < 0 ||
|
||||
if (argcount < posonlyargcount || posonlyargcount < 0 ||
|
||||
kwonlyargcount < 0 || nlocals < 0 ||
|
||||
stacksize < 0 || flags < 0 ||
|
||||
code == NULL || !PyBytes_Check(code) ||
|
||||
consts == NULL || !PyTuple_Check(consts) ||
|
||||
names == NULL || !PyTuple_Check(names) ||
|
||||
|
@ -152,11 +153,9 @@ PyCode_New(int argcount, int posonlyargcount, int kwonlyargcount,
|
|||
}
|
||||
|
||||
n_varnames = PyTuple_GET_SIZE(varnames);
|
||||
if (posonlyargcount + argcount <= n_varnames
|
||||
&& kwonlyargcount <= n_varnames) {
|
||||
if (argcount <= n_varnames && kwonlyargcount <= n_varnames) {
|
||||
/* Never overflows. */
|
||||
total_args = (Py_ssize_t)posonlyargcount + (Py_ssize_t)argcount
|
||||
+ (Py_ssize_t)kwonlyargcount +
|
||||
total_args = (Py_ssize_t)argcount + (Py_ssize_t)kwonlyargcount +
|
||||
((flags & CO_VARARGS) != 0) + ((flags & CO_VARKEYWORDS) != 0);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue