diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2019-06-01 18:08:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-01 18:08:04 +0100 |
commit | cd74e66a8c420be675fd2fbf3fe708ac02ee9f21 (patch) | |
tree | 12f985512507967c339019c4c21b4a613cd6c61b /Objects/codeobject.c | |
parent | 059b9ea5ac98f432e41b05d1fa5aab4ffa22df4d (diff) | |
download | cpython-git-cd74e66a8c420be675fd2fbf3fe708ac02ee9f21.tar.gz |
bpo-37122: Make co->co_argcount represent the total number of positonal arguments in the code object (GH-13726)
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r-- | Objects/codeobject.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 886ce41944..bf68e54f42 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -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 { |