diff --git a/test/bytecode_pypy3.6/00_import.pyc b/test/bytecode_pypy3.6/00_import.pyc new file mode 100644 index 00000000..e7f4ccfc Binary files /dev/null and b/test/bytecode_pypy3.6/00_import.pyc differ diff --git a/test/bytecode_pypy3.6/00_assign.pyc b/test/bytecode_pypy3.6_run/00_assign.pyc similarity index 100% rename from test/bytecode_pypy3.6/00_assign.pyc rename to test/bytecode_pypy3.6_run/00_assign.pyc diff --git a/uncompyle6/semantics/customize.py b/uncompyle6/semantics/customize.py index 9f2a0149..fe3c5688 100644 --- a/uncompyle6/semantics/customize.py +++ b/uncompyle6/semantics/customize.py @@ -29,6 +29,9 @@ def customize_for_version(self, is_pypy, version): ####################### TABLE_DIRECT.update({ 'assert_pypy': ( '%|assert %c\n' , (1, 'assert_expr') ), + # This is as a result of an if transoration + 'assert0_pypy': ( '%|assert %c\n' , (0, 'assert_expr') ), + 'assert_not_pypy': ( '%|assert not %c\n' , (1, 'assert_exp') ), 'assert2_not_pypy': ( '%|assert not %c, %c\n' , (1, 'assert_exp'), (4, 'expr') ), diff --git a/uncompyle6/semantics/fragments.py b/uncompyle6/semantics/fragments.py index 7e7a5ca6..a297a15c 100644 --- a/uncompyle6/semantics/fragments.py +++ b/uncompyle6/semantics/fragments.py @@ -187,6 +187,7 @@ class FragmentsWalker(pysource.SourceWalker, object): self.hide_internal = False self.offsets = {} self.last_finish = -1 + self.is_pypy = is_pypy # FIXME: is there a better way? global MAP_DIRECT_FRAGMENT diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index b78c26cf..19e4f37c 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -239,7 +239,9 @@ class SourceWalker(GenericASTTraversal, object): is_pypy=is_pypy, ) - self.treeTransform = TreeTransform(version, showast) + self.treeTransform = TreeTransform(version=version, + show_ast=showast, + is_pypy=is_pypy) self.debug_parser = dict(debug_parser) self.showast = showast self.params = params diff --git a/uncompyle6/semantics/transform.py b/uncompyle6/semantics/transform.py index a194c964..6096b5bb 100644 --- a/uncompyle6/semantics/transform.py +++ b/uncompyle6/semantics/transform.py @@ -30,9 +30,11 @@ def is_docstring(node): class TreeTransform(GenericASTTraversal, object): - def __init__(self, version, show_ast=None): + def __init__(self, version, show_ast=None, + is_pypy=False): self.version = version self.showast = show_ast + self.is_pypy = is_pypy return def maybe_show_tree(self, ast): @@ -133,7 +135,10 @@ class TreeTransform(GenericASTTraversal, object): # becomes: # assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 COME_FROM if jump_cond == "jmp_true": - kind = "assert" + if self.is_pypy: + kind = "assert0_pypy" + else: + kind = "assert" else: assert jump_cond == "jmp_false" kind = "assertnot"