# HG changeset patch # User Paul Boddie # Date 1490378821 -3600 # Node ID 54dd15ef07b26443c4d736a71530fda6c70d5933 # Parent 41eddb32a6037b5418cd64add2041d89a929a833# Parent 09f0039c42cb9f54c99a25735df4db2168128049 Merged changes from the default branch. diff -r 41eddb32a603 -r 54dd15ef07b2 templates/ops.c --- a/templates/ops.c Thu Mar 23 23:36:32 2017 +0100 +++ b/templates/ops.c Fri Mar 24 19:07:01 2017 +0100 @@ -326,8 +326,11 @@ __attr (*__get_function(__attr context, __attr target))(__attr[]) { - target = __unwrap_callable(target); + return __get_function_unwrapped(context, __unwrap_callable(target)); +} +__attr (*__get_function_unwrapped(__attr context, __attr target))(__attr[]) +{ /* Require null or instance contexts for functions and methods respectively, or type instance contexts for type methods. */ @@ -339,8 +342,11 @@ __attr (*__check_and_get_function(__attr context, __attr target))(__attr[]) { - target = __unwrap_callable(target); + return __check_and_get_function_unwrapped(context, __unwrap_callable(target)); +} +__attr (*__check_and_get_function_unwrapped(__attr context, __attr target))(__attr[]) +{ /* Require null or instance contexts for functions and methods respectively, or type instance contexts for type methods. */ diff -r 41eddb32a603 -r 54dd15ef07b2 templates/ops.h --- a/templates/ops.h Thu Mar 23 23:36:32 2017 +0100 +++ b/templates/ops.h Fri Mar 24 19:07:01 2017 +0100 @@ -114,7 +114,9 @@ __attr __unwrap_callable(__attr callable); __attr (*__get_function_unchecked(__attr target))(__attr[]); __attr (*__get_function(__attr context, __attr target))(__attr[]); +__attr (*__get_function_unwrapped(__attr context, __attr target))(__attr[]); __attr (*__check_and_get_function(__attr context, __attr target))(__attr[]); +__attr (*__check_and_get_function_unwrapped(__attr context, __attr target))(__attr[]); /* Parameter position operations. */ diff -r 41eddb32a603 -r 54dd15ef07b2 templates/progops.c --- a/templates/progops.c Thu Mar 23 23:36:32 2017 +0100 +++ b/templates/progops.c Fri Mar 24 19:07:01 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; @@ -253,7 +261,10 @@ /* Call with the prepared arguments. */ - return (always_callable ? __get_function(allargs[0], target) : __check_and_get_function(allargs[0], target))(allargs); + return (always_callable ? + __get_function_unwrapped(allargs[0], target) : + __check_and_get_function_unwrapped(allargs[0], target) + )(allargs); } /* Error routines. */