diff --git a/test/bytecode_3.6_run/02_call_ex_kw.pyc b/test/bytecode_3.6_run/02_call_ex_kw.pyc index eafc74c4..8ca39997 100644 Binary files a/test/bytecode_3.6_run/02_call_ex_kw.pyc and b/test/bytecode_3.6_run/02_call_ex_kw.pyc differ diff --git a/test/simple_source/bug36/02_call_ex_kw.py b/test/simple_source/bug36/02_call_ex_kw.py index 1e0a8f24..ee996298 100644 --- a/test/simple_source/bug36/02_call_ex_kw.py +++ b/test/simple_source/bug36/02_call_ex_kw.py @@ -1,6 +1,6 @@ # From #227 # Bug was not handling call_ex_kw correctly -# THis appears in +# This appears in # showparams(c, test="A", **extra_args) # below @@ -10,4 +10,28 @@ def showparams(c, test, **extra_args): def f(c, **extra_args): return showparams(c, test="A", **extra_args) +def f1(c, d, **extra_args): + return showparams(c, test="B", **extra_args) + +def f2(**extra_args): + return showparams(1, test="C", **extra_args) + assert f(1, a=2, b=3) == {'c': 1, 'a': 2, 'b': 3, 'test': 'A'} + +a = {'param1': 2} +assert f1('2', '{\'test\': "4"}', test2='a', **a) \ + == {'c': '2', 'test2': 'a', 'param1': 2, 'test': 'B'} +assert f1(2, '"3"', test2='a', **a) \ + == {'c': 2, 'test2': 'a', 'param1': 2, 'test': 'B'} +assert f1(False, '"3"', test2='a', **a) \ + == {'c': False, 'test2': 'a', 'param1': 2, 'test': 'B'} +assert f(2, test2='A', **a) \ + == {'c': 2, 'test2': 'A', 'param1': 2, 'test': 'A'} +assert f(str(2) + str(1), test2='a', **a) \ + == {'c': '21', 'test2': 'a', 'param1': 2, 'test': 'A'} +assert f1((a.get('a'), a.get('b')), a, test3='A', **a) \ + == {'c': (None, None), 'test3': 'A', 'param1': 2, 'test': 'B'} + +b = {'b1': 1, 'b2': 2} +assert f2(**a, **b) == \ + {'c': 1, 'param1': 2, 'b1': 1, 'b2': 2, 'test': 'C'} diff --git a/uncompyle6/semantics/customize36.py b/uncompyle6/semantics/customize36.py index 1711fd53..98f0f86e 100644 --- a/uncompyle6/semantics/customize36.py +++ b/uncompyle6/semantics/customize36.py @@ -128,22 +128,22 @@ def customize_for_version36(self, version): expr = node[1] assert expr == 'expr' value = self.traverse(expr, indent='') - + if value.startswith('('): value = value[1:-1].rstrip(" ") # Remove starting '(' and trailing ')' and additional spaces - if value == '': - fmt = "%%c(%%p)" % () # args is empty + if value == '': + fmt = "%c(%p)" # args is empty else: if value.endswith(','): # if args has only one item value = value[:-1] fmt = "%%c(%s, %%p)" % value else: fmt = "%%c(%s, %%p)" % value - + self.template_engine( (fmt, (0, 'expr'), (2, 'build_map_unpack_with_call', 100)), node) - + self.prune() self.n_call_ex_kw = call_ex_kw