# HG changeset patch # User Paul Boddie # Date 1490392006 -3600 # Node ID c731ec23e6b10dc0948474eda9122e6ca4c37af0 # Parent 9c393bfc03d5830b99104f9a89b2d3d22174b332# Parent 54dd15ef07b26443c4d736a71530fda6c70d5933 Merged changes from the integers-as-tagged-attrs branch. diff -r 9c393bfc03d5 -r c731ec23e6b1 templates/ops.c --- a/templates/ops.c Fri Mar 24 22:39:37 2017 +0100 +++ b/templates/ops.c Fri Mar 24 22:46:46 2017 +0100 @@ -326,8 +326,11 @@ __attr (*__get_function(__attr context, __attr target))() { - 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))() { - 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 9c393bfc03d5 -r c731ec23e6b1 templates/ops.h --- a/templates/ops.h Fri Mar 24 22:39:37 2017 +0100 +++ b/templates/ops.h Fri Mar 24 22:46:46 2017 +0100 @@ -114,7 +114,9 @@ __attr __unwrap_callable(__attr callable); __attr (*__get_function_unchecked(__attr target))(); __attr (*__get_function(__attr context, __attr target))(); +__attr (*__get_function_unwrapped(__attr context, __attr target))(); __attr (*__check_and_get_function(__attr context, __attr target))(); +__attr (*__check_and_get_function_unwrapped(__attr context, __attr target))(); /* Parameter position operations. */ diff -r 9c393bfc03d5 -r c731ec23e6b1 templates/progops.c --- a/templates/progops.c Fri Mar 24 22:39:37 2017 +0100 +++ b/templates/progops.c Fri Mar 24 22:46:46 2017 +0100 @@ -186,14 +186,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; @@ -238,8 +246,8 @@ return __call_with_args( always_callable ? - __get_function(allargs[0], target) : - __check_and_get_function(allargs[0], target), + __get_function_unwrapped(allargs[0], target) : + __check_and_get_function_unwrapped(allargs[0], target), allargs, max); }