Commit 0d598eb9 authored by Stefan Behnel's avatar Stefan Behnel

fix crash in argument unpacking when receiving insufficient keyword arguments

--HG--
extra : transplant_source : %F9t%A6p%841%A5%40%60R%24I%A7%E2%5E%8F%5Cj%ABf
parent d4fc2b2c
...@@ -2781,7 +2781,7 @@ class DefNode(FuncDefNode): ...@@ -2781,7 +2781,7 @@ class DefNode(FuncDefNode):
# If we received kwargs, fill up the positional/required # If we received kwargs, fill up the positional/required
# arguments with values from the kw dict # 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: if self.num_required_args or max_positional_args > 0:
last_required_arg = -1 last_required_arg = -1
for i, arg in enumerate(all_args): for i, arg in enumerate(all_args):
...@@ -2888,7 +2888,6 @@ class DefNode(FuncDefNode): ...@@ -2888,7 +2888,6 @@ class DefNode(FuncDefNode):
self.name)) self.name))
code.putln(code.error_goto(self.pos)) code.putln(code.error_goto(self.pos))
code.putln('}') code.putln('}')
code.putln('}')
def generate_argument_conversion_code(self, code): def generate_argument_conversion_code(self, code):
# Generate code to convert arguments from signature type to # 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