Commit 1a2d1558 authored by Stefan Behnel's avatar Stefan Behnel

fix crash in argument unpacking when receiving insufficient keyword arguments

parent 65f57569
......@@ -2830,7 +2830,7 @@ class DefNode(FuncDefNode):
# If we received kwargs, fill up the positional/required
# arguments with values from the kw dict
code.putln('if (likely((kw_args = PyDict_Size(%s)) > 0)) {' % Naming.kwds_cname)
code.putln('kw_args = PyDict_Size(%s);' % Naming.kwds_cname)
if self.num_required_args or max_positional_args > 0:
last_required_arg = -1
for i, arg in enumerate(all_args):
......@@ -2937,7 +2937,6 @@ class DefNode(FuncDefNode):
self.name))
code.putln(code.error_goto(self.pos))
code.putln('}')
code.putln('}')
def generate_argument_conversion_code(self, code):
# Generate code to convert arguments from signature type to
......
# mode: run
def test_single_arg(a):
"""
>>> test_single_arg(1)
1
>>> test_single_arg() # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_single_arg(1,2) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_single_arg(**{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_single_arg(*(), **{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
"""
return a
def test_two_args(a,b):
"""
>>> test_two_args(1,2)
(1, 2)
>>> test_two_args() # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(1) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(1,2,3) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(**{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(1, **{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
>>> test_two_args(*(), **{}) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
"""
return a,b
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