From: Robert Bradshaw Date: Wed, 23 Jan 2008 00:23:46 +0000 (-0800) Subject: Fix to prepositional args parsing when self present. X-Git-Tag: 0.9.6.14~29^2~60 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5fa9063eef35f3b382e95b04a517e6437e5c44ce;p=cython.git Fix to prepositional args parsing when self present. Thanks to Stefan Behnel for pointing this out. --- 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)