# HG changeset patch # User Paul Boddie # Date 1490377979 -3600 # Node ID 09f0039c42cb9f54c99a25735df4db2168128049 # Parent 05930170914dd0e06c5c2363d55a0e4e41633171 Test for the presence of the exact number of required arguments first. diff -r 05930170914d -r 09f0039c42cb templates/progops.c --- a/templates/progops.c Fri Mar 24 17:44:52 2017 +0100 +++ b/templates/progops.c Fri Mar 24 18:52:59 2017 +0100 @@ -204,14 +204,22 @@ unsigned int pos, kwpos; /* Check the number of arguments. */ + + if ((nargs == max) && (nkwargs == 0)) + { + /* pass */ + } + /* NOTE: Should use a more specific exception. */ - if ((min > (nargs + nkwargs)) || ((nargs + nkwargs) > max)) + else if ((min > (nargs + nkwargs)) || ((nargs + nkwargs) > max)) + { __raise_type_error(); + } /* Copy the arguments. */ - if (nargs < max) + else if (nargs < max) { allargs = moreargs;