Commit f0472a34 authored by Stefan Behnel's avatar Stefan Behnel

comments

parent 92b1ba43
...@@ -1768,8 +1768,7 @@ class DefNode(FuncDefNode): ...@@ -1768,8 +1768,7 @@ class DefNode(FuncDefNode):
code.putln("Py_ssize_t kw_args = PyDict_Size(%s);" % code.putln("Py_ssize_t kw_args = PyDict_Size(%s);" %
Naming.kwds_cname) Naming.kwds_cname)
# parse the tuple first, then start parsing the arg tuple and # parse the tuple and check that there are not too many
# check that positional args are not also passed as kw args
code.putln('switch (PyTuple_GET_SIZE(%s)) {' % Naming.args_cname) code.putln('switch (PyTuple_GET_SIZE(%s)) {' % Naming.args_cname)
for i in range(max_positional_args-1, -1, -1): for i in range(max_positional_args-1, -1, -1):
code.putln('case %d:' % (i+1)) code.putln('case %d:' % (i+1))
...@@ -1826,11 +1825,12 @@ class DefNode(FuncDefNode): ...@@ -1826,11 +1825,12 @@ class DefNode(FuncDefNode):
# pure error case: keywords required but not passed # pure error case: keywords required but not passed
code.putln('} else {') code.putln('} else {')
if not self.star_arg and not self.starstar_arg: if not self.star_arg and not self.starstar_arg:
# optional args missing?
self.generate_positional_args_check( self.generate_positional_args_check(
max_positional_args, has_fixed_positional_count, code) max_positional_args, has_fixed_positional_count, code)
# simple case: keywords required but none passed
for i, arg in enumerate(kw_only_args): for i, arg in enumerate(kw_only_args):
if not arg.default: if not arg.default:
# required keyword-only argument missing
code.put('__Pyx_RaiseKeywordRequired("%s", *%s[%d]); ' % ( code.put('__Pyx_RaiseKeywordRequired("%s", *%s[%d]); ' % (
self.name.utf8encode(), Naming.pykwdlist_cname, self.name.utf8encode(), Naming.pykwdlist_cname,
len(positional_args) + i)) len(positional_args) + i))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment