diff --git a/Makefile b/Makefile index 4be5dca5..bbba91b7 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ check-2.6: #:PyPy 2.6.1 or PyPy 5.0.1 # Skip for now -2.6 5.0: +2.6 5.0 5.3: #:PyPy pypy3-2.4.0 Python 3: pypy-3.2 2.4: diff --git a/test/bytecode_2.4/04_comp_for.pyc b/test/bytecode_2.4/04_comp_for.pyc new file mode 100644 index 00000000..48d75b2e Binary files /dev/null and b/test/bytecode_2.4/04_comp_for.pyc differ diff --git a/test/bytecode_2.6/04_comp_for.pyc b/test/bytecode_2.6/04_comp_for.pyc new file mode 100644 index 00000000..3b524d50 Binary files /dev/null and b/test/bytecode_2.6/04_comp_for.pyc differ diff --git a/test/simple_source/bug26/04_comp_for.py b/test/simple_source/bug26/04_comp_for.py new file mode 100644 index 00000000..3fbe67e7 --- /dev/null +++ b/test/simple_source/bug26/04_comp_for.py @@ -0,0 +1,4 @@ +# From python2.6/_abcoll.py +# Bug was wrong code for "comp_for" giving +# "for in x" instead of: "for x in y" +chain = (e for s in (self, other) for x in y) diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 078bd0cb..c08cc8ab 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -223,7 +223,6 @@ TABLE_DIRECT = { 'lc_body': ( '', ), # ignore when recusing 'comp_iter': ( '%c', 0), - 'comp_for': ( ' for %c in %c%c', 2, 0, 3 ), 'comp_if': ( ' if %c%c', 0, 2 ), 'comp_ifnot': ( ' if not %p%c', (0, 22), 2 ), 'comp_body': ( '', ), # ignore when recusing @@ -596,6 +595,14 @@ class SourceWalker(GenericASTTraversal, object): TABLE_DIRECT.update({ 'except_cond3': ( '%|except %c, %c:\n', 1, 6 ), }) + if 2.4 <= version <= 2.6: + TABLE_DIRECT.update({ + 'comp_for': ( ' for %c in %c', 3, 1 ), + }) + else: + TABLE_DIRECT.update({ + 'comp_for': ( ' for %c in %c%c', 2, 0, 3 ), + }) ##########################