From 5fa9063eef35f3b382e95b04a517e6437e5c44ce Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Tue, 22 Jan 2008 16:23:46 -0800 Subject: [PATCH] Fix to prepositional args parsing when self present. Thanks to Stefan Behnel for pointing this out. --- Cython/Compiler/Nodes.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index dae5d175..9e6dc7ba 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1255,18 +1255,21 @@ class DefNode(FuncDefNode): our_error_label = code.error_label end_label = code.new_label() # Unpack inplace if it's simple + has_self_arg = len(self.args) > 0 and self.args[0].is_self_arg if self.num_required_args == len(self.args): - count_cond = "PyTuple_GET_SIZE(%s) == %s" % (Naming.args_cname, self.num_required_args) + count_cond = "PyTuple_GET_SIZE(%s) == %s" % (Naming.args_cname, self.num_required_args - has_self_arg) else: count_cond = "%s <= PyTuple_GET_SIZE(%s) && PyTuple_GET_SIZE(%s) <= %s" % ( - self.num_required_args, + self.num_required_args - has_self_arg, Naming.args_cname, Naming.args_cname, - len(self.args)) + len(self.args) - has_self_arg) code.putln( 'if (likely(%s == NULL && %s)) {' % (Naming.kwds_cname, count_cond)) i = 0 for arg in self.args: + if arg.is_self_arg: + continue if arg.default: code.putln('if (PyTuple_GET_SIZE(%s) > %s) {' % (Naming.args_cname, i)) item = "PyTuple_GET_ITEM(%s, %s)" % (Naming.args_cname, i) -- 2.26.2