diff --git a/test/bytecode_3.5/03_double_star_unpack.pyc b/test/bytecode_3.5/03_double_star_unpack.pyc index 33111dd0..94544203 100644 Binary files a/test/bytecode_3.5/03_double_star_unpack.pyc and b/test/bytecode_3.5/03_double_star_unpack.pyc differ diff --git a/test/simple_source/bug35/03_double_star_unpack.py b/test/simple_source/bug35/03_double_star_unpack.py index e5c330ad..9901d371 100644 --- a/test/simple_source/bug35/03_double_star_unpack.py +++ b/test/simple_source/bug35/03_double_star_unpack.py @@ -1,9 +1,17 @@ -# Bug in Python 3.5 is getting the two star'd arguments right. -def sum(a,b,c,d): +# Bug in 3.5 is detecting when there is more than +# one * in a call. There is a "BUILD_UNPACK_LIST" instruction used +# to unpack star arguments +def sum(a, b, c, d): return a + b + c + d - -args=(1,2) +a, b, c = 1, 2, 3 +args = (1, 2) sum(*args, *args) +# FIXME: these is handled incorrectly + +# sum(a, *args, *args) + +# sum(a, b, *args) + # FIXME: this is handled incorrectly # (*c,) = (3,4) diff --git a/uncompyle6/semantics/customize.py b/uncompyle6/semantics/customize.py index fb646df0..34a5e032 100644 --- a/uncompyle6/semantics/customize.py +++ b/uncompyle6/semantics/customize.py @@ -282,12 +282,22 @@ def customize_for_version(self, is_pypy, version): node[kwarg_pos], node[args_pos] = node[args_pos], node[kwarg_pos] args_pos = kwarg_pos kwarg_pos += 1 - elif key.kind == 'CALL_FUNCTION_VAR_0' and node[1][0] == 'build_list_unpack': - self.preorder(node[0]) - build_list_unpack = node[1][0] - template = ('(*%P)', (0, len(build_list_unpack)-1, ', *', 100)) - self.template_engine(template, build_list_unpack) - self.prune() + elif key.kind.startswith('CALL_FUNCTION_VAR'): + nargs = node[-1].attr + args_node = node[-2] + if args_node == 'pos_arg': + args_node = args_node[0] + if args_node == 'expr': + args_node = args_node[0] + if nargs > 0: + template = ('%c(%C, ', 0, (0, nargs, ', ')) + else: + template = ('%c(', 0) + self.template_engine(template, node) + if args_node == 'build_list_unpack': + template = ('*%P)', (0, len(args_node)-1, ', *', 100)) + self.template_engine(template, args_node) + self.prune() self.default(node) self.n_call = n_call