diff --git a/test/bytecode_3.6_run/04_call_function.pyc b/test/bytecode_3.6_run/04_call_function.pyc index 82245f92..da2cb65f 100644 Binary files a/test/bytecode_3.6_run/04_call_function.pyc and b/test/bytecode_3.6_run/04_call_function.pyc differ diff --git a/uncompyle6/semantics/customize.py b/uncompyle6/semantics/customize.py index 95b5c7df..c30def1f 100644 --- a/uncompyle6/semantics/customize.py +++ b/uncompyle6/semantics/customize.py @@ -408,6 +408,7 @@ def customize_for_version(self, is_pypy, version): # Value 100 is important; it is exactly # module/function precidence. PRECEDENCE['call_kw'] = 100 + PRECEDENCE['call_ex'] = 100 TABLE_DIRECT.update({ 'tryfinally36': ( '%|try:\n%+%c%-%|finally:\n%+%c%-\n\n', @@ -421,11 +422,11 @@ def customize_for_version(self, is_pypy, version): 'try_except36': ( '%|try:\n%+%c%-%c\n\n', 1, 2 ), 'unpack_list': ( '*%c', (0, 'list') ), 'call_ex' : ( - '%c(%c)', - (0, 'expr'), 1), + '%c(%p)', + (0, 'expr'), (1, 100)), 'call_ex_kw' : ( - '%c(%c)', - (0, 'expr'), 2), + '%c(%p)', + (0, 'expr'), (2, 100)), }) @@ -533,8 +534,11 @@ def customize_for_version(self, is_pypy, version): kwargs = node[2] if kwargs == 'expr': kwargs = kwargs[0] - self.write('**') - self.preorder(kwargs) + if kwargs == 'dict': + self.call36_dict(kwargs) + else: + self.write('**') + self.preorder(kwargs) self.write(')') self.prune() self.n_call_ex_kw3 = call_ex_kw3 @@ -561,6 +565,7 @@ def customize_for_version(self, is_pypy, version): kwargs = kwargs[0] call_function_ex = node[-1] assert call_function_ex == 'CALL_FUNCTION_EX_KW' + # FIXME: decide if the below test be on kwargs == 'dict' if (call_function_ex.attr & 1 and (not isinstance(kwargs, Token) and kwargs != 'attribute')): self.call36_dict(kwargs) @@ -767,9 +772,18 @@ def customize_for_version(self, is_pypy, version): if pos_args == 'expr': pos_args = pos_args[0] if pos_args == 'tuple': + build_tuple = pos_args[0] + if build_tuple.kind.startswith('BUILD_TUPLE'): + tuple_len = 0 + else: + tuple_len = len(node) - 1 star_start = 1 template = '%C', (0, -1, ', ') self.template_engine(template, pos_args) + if tuple_len == 0: + self.write("*()") + # That's it + self.prune() self.write(', ') else: star_start = 0 @@ -777,6 +791,7 @@ def customize_for_version(self, is_pypy, version): template = ( '*%C', (star_start, -1, ', *') ) else: template = ( '*%c', (star_start, 'expr') ) + self.template_engine(template, node) self.prune()