Fix a bug in 3.6+ keyword-only argument passing

This commit is contained in:
rocky 2020-01-21 04:37:58 -05:00
parent e466e826b3
commit beac1d3567
6 changed files with 7 additions and 3 deletions

View File

@ -53,3 +53,9 @@ from collections import namedtuple
Point = namedtuple('Point', 'x y')
p = Point(11, 22)
assert p == Point(**dict(x=11, y=22))
# From 3.7 test/test_keywordonlyarg.py
# Bug was in handling {"4":4} as a dictionary needing **
def posonly_sum(pos_arg1, *arg, **kwarg):
return pos_arg1 + sum(arg) + sum(kwarg.values())
assert 1+2+3+4 == posonly_sum(1,*(2,3),**{"4":4})

View File

@ -88,7 +88,6 @@ SKIP_TESTS=(
[test_inspect.py]=1 # Syntax error Investigate
[test_itertools.py]=1 #
[test_keywordonlyarg.py]=1 # Investigate
[test_kqueue.py]=1 # it fails on its own
[test_lib2to3.py]=1 # it fails on its own

View File

@ -54,7 +54,6 @@ SKIP_TESTS=(
[test_index.py]=1 # parse error
[test_inspect.py]=1 # test failures
[test_itertools.py]=1 # parse error
[test_keywordonlyarg.py]=1 # Investigate: parameter handling
[test_kqueue.py]=1 # it fails on its own
[test_lib2to3.py]=1 # it fails on its own
[test_long.py]=1 # investigate

View File

@ -188,7 +188,7 @@ def customize_for_version36(self, version):
self.write(', ')
kwargs = node[2]
if kwargs == 'expr':
if kwargs == 'expr' and kwargs[0] != "dict":
kwargs = kwargs[0]
if kwargs == 'dict':
self.call36_dict(kwargs)