Lichen

Changeset

760:09f0039c42cb
2017-03-24 Paul Boddie raw files shortlog changelog graph Test for the presence of the exact number of required arguments first.
templates/progops.c (file)
     1.1 --- a/templates/progops.c	Fri Mar 24 17:44:52 2017 +0100
     1.2 +++ b/templates/progops.c	Fri Mar 24 18:52:59 2017 +0100
     1.3 @@ -204,14 +204,22 @@
     1.4      unsigned int pos, kwpos;
     1.5  
     1.6      /* Check the number of arguments. */
     1.7 +
     1.8 +    if ((nargs == max) && (nkwargs == 0))
     1.9 +    {
    1.10 +        /* pass */
    1.11 +    }
    1.12 +
    1.13      /* NOTE: Should use a more specific exception. */
    1.14  
    1.15 -    if ((min > (nargs + nkwargs)) || ((nargs + nkwargs) > max))
    1.16 +    else if ((min > (nargs + nkwargs)) || ((nargs + nkwargs) > max))
    1.17 +    {
    1.18          __raise_type_error();
    1.19 +    }
    1.20  
    1.21      /* Copy the arguments. */
    1.22  
    1.23 -    if (nargs < max)
    1.24 +    else if (nargs < max)
    1.25      {
    1.26          allargs = moreargs;
    1.27