diff --git a/test/bytecode_2.1/00_import.pyc b/test/bytecode_2.1/00_import.pyc index fed3667a..f3f3da82 100644 Binary files a/test/bytecode_2.1/00_import.pyc and b/test/bytecode_2.1/00_import.pyc differ diff --git a/test/bytecode_2.2/00_import.pyc b/test/bytecode_2.2/00_import.pyc index 3d9fbd01..96dce7df 100644 Binary files a/test/bytecode_2.2/00_import.pyc and b/test/bytecode_2.2/00_import.pyc differ diff --git a/test/bytecode_2.3/00_import.pyc b/test/bytecode_2.3/00_import.pyc index e2755523..5701ad7b 100644 Binary files a/test/bytecode_2.3/00_import.pyc and b/test/bytecode_2.3/00_import.pyc differ diff --git a/test/bytecode_2.4/00_import.pyc b/test/bytecode_2.4/00_import.pyc index b711ca9f..e8693994 100644 Binary files a/test/bytecode_2.4/00_import.pyc and b/test/bytecode_2.4/00_import.pyc differ diff --git a/test/bytecode_2.5/00_import.pyc b/test/bytecode_2.5/00_import.pyc index 64e32f51..fc0377f4 100644 Binary files a/test/bytecode_2.5/00_import.pyc and b/test/bytecode_2.5/00_import.pyc differ diff --git a/test/bytecode_2.6/00_import.pyc b/test/bytecode_2.6/00_import.pyc index ec02a67b..5425f49f 100644 Binary files a/test/bytecode_2.6/00_import.pyc and b/test/bytecode_2.6/00_import.pyc differ diff --git a/test/bytecode_2.7/00_import.pyc b/test/bytecode_2.7/00_import.pyc index 38f74f6b..62d8bd77 100644 Binary files a/test/bytecode_2.7/00_import.pyc and b/test/bytecode_2.7/00_import.pyc differ diff --git a/test/bytecode_3.3/00_import.pyc b/test/bytecode_3.3/00_import.pyc index 6ffd1757..0c9e5407 100644 Binary files a/test/bytecode_3.3/00_import.pyc and b/test/bytecode_3.3/00_import.pyc differ diff --git a/test/bytecode_3.4/00_import.pyc b/test/bytecode_3.4/00_import.pyc index 4a455a04..6174ea0a 100644 Binary files a/test/bytecode_3.4/00_import.pyc and b/test/bytecode_3.4/00_import.pyc differ diff --git a/test/bytecode_3.5/00_import.pyc b/test/bytecode_3.5/00_import.pyc index b96f8054..9484a59d 100644 Binary files a/test/bytecode_3.5/00_import.pyc and b/test/bytecode_3.5/00_import.pyc differ diff --git a/test/bytecode_3.5/01_ops.pyc b/test/bytecode_3.5/01_ops.pyc new file mode 100644 index 00000000..9166a5c3 Binary files /dev/null and b/test/bytecode_3.5/01_ops.pyc differ diff --git a/test/bytecode_3.6/00_import.pyc b/test/bytecode_3.6/00_import.pyc index c903cd67..9326c33b 100644 Binary files a/test/bytecode_3.6/00_import.pyc and b/test/bytecode_3.6/00_import.pyc differ diff --git a/test/simple_source/bug30/01_ops.py b/test/simple_source/bug30/01_ops.py index 3e03ca0b..9dfb189b 100644 --- a/test/simple_source/bug30/01_ops.py +++ b/test/simple_source/bug30/01_ops.py @@ -1,5 +1,8 @@ # Statements to beef up grammar coverage rules # Force "inplace" ops +# Note this is like simple_source/bug22/01_ops.py +# But we don't ahve the UNARY_CONVERT which dropped +# out around 2.7 y = +10 # UNARY_POSITIVE y /= 1 # INPLACE_DIVIDE y %= 4 # INPLACE_MODULO diff --git a/test/simple_source/stmts/00_import.py b/test/simple_source/stmts/00_import.py index eaee8271..33cbb1a3 100644 --- a/test/simple_source/stmts/00_import.py +++ b/test/simple_source/stmts/00_import.py @@ -1,6 +1,9 @@ -# Tests: +# Tests all the different kinds of imports import sys from os import path from os import * import time as time1, os as os1 import http.client as httpclient +if len(__file__) == 0: + # a.b.c should force consecutive LOAD_ATTRs + import a.b.c as d diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index d5632cf5..5c693654 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -620,17 +620,18 @@ class Python3Parser(PythonParser): load_attr ::= expr LOOKUP_METHOD call ::= expr CALL_METHOD """ + is_pypy = False seen_LOAD_BUILD_CLASS = False seen_LOAD_DICTCOMP = False seen_LOAD_LISTCOMP = False seen_LOAD_SETCOMP = False - seen_classdeco_end = False seen_GET_AWAITABLE_YIELD_FROM = False # Loop over instructions adding custom grammar rules based on # a specific instruction seen. if 'PyPy' in customize: + is_pypy = True self.addRule(""" stmt ::= assign3_pypy stmt ::= assign2_pypy @@ -825,9 +826,12 @@ class Python3Parser(PythonParser): # Note: this probably doesn't handle kwargs proprerly args_pos, args_kw, annotate_args = token.attr - rule_pat = ('mklambda ::= %sload_closure LOAD_LAMBDA %%s%s' % - ('pos_arg '* args_pos, opname)) - self.add_make_function_rule(rule_pat, opname, token.attr, customize) + # FIXME: Fold test into add_make_function_rule + j = 1 if self.version < 3.3 else 2 + if is_pypy or (i > j and tokens[i-j] == 'LOAD_LAMBDA'): + rule_pat = ('mklambda ::= %sload_closure LOAD_LAMBDA %%s%s' % + ('pos_arg '* args_pos, opname)) + self.add_make_function_rule(rule_pat, opname, token.attr, customize) if has_get_iter_call_function1: rule_pat = ("generator_exp ::= %sload_closure load_genexpr %%s%s expr " @@ -889,11 +893,12 @@ class Python3Parser(PythonParser): "GET_ITER CALL_FUNCTION_1" % ('pos_arg '* args_pos, opname)) self.add_make_function_rule(rule_pat, opname, token.attr, customize) - rule_pat = ('mklambda ::= %s%sLOAD_LAMBDA %%s%s' % - (('pos_arg '* args_pos), - ('kwarg '* args_kw), - opname)) - self.add_make_function_rule(rule_pat, opname, token.attr, customize) + if is_pypy or (i > 2 and tokens[i-2] == 'LOAD_LAMBDA'): + rule_pat = ('mklambda ::= %s%sLOAD_LAMBDA %%s%s' % + (('pos_arg '* args_pos), + ('kwarg '* args_kw), + opname)) + self.add_make_function_rule(rule_pat, opname, token.attr, customize) if seen_LOAD_LISTCOMP and has_get_iter_call_function1: rule_pat = ("listcomp ::= %sLOAD_LISTCOMP %%s%s expr " "GET_ITER CALL_FUNCTION_1" % ('expr ' * args_pos, opname)) @@ -908,11 +913,15 @@ class Python3Parser(PythonParser): rule_pat = ("generator_exp ::= %sload_genexpr %%s%s expr " "GET_ITER CALL_FUNCTION_1" % ('pos_arg '* args_pos, opname)) self.add_make_function_rule(rule_pat, opname, token.attr, customize) - rule_pat = ('mklambda ::= %s%sLOAD_LAMBDA %%s%s' % - (('pos_arg '* args_pos), - ('kwarg '* args_kw), - opname)) - self.add_make_function_rule(rule_pat, opname, token.attr, customize) + + # FIXME: Fold test into add_make_function_rule + j = 1 if self.version < 3.3 else 2 + if is_pypy or (i > j and tokens[i-j] == 'LOAD_LAMBDA'): + rule_pat = ('mklambda ::= %s%sLOAD_LAMBDA %%s%s' % + (('pos_arg '* args_pos), + ('kwarg '* args_kw), + opname)) + self.add_make_function_rule(rule_pat, opname, token.attr, customize) if seen_LOAD_LISTCOMP and has_get_iter_call_function1: rule_pat = ("listcomp ::= %sLOAD_LISTCOMP %%s%s expr "