From 52a35e6c62955137d7d927f07e5d4faddd7cdf5b Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 3 Sep 2016 00:30:48 -0400 Subject: [PATCH] Fix Python 2.4-2.6 comp_for text generation... Makefile: tolerate pypy 5.3.x Rest: fix semantic action rule for comp_for and test this --- Makefile | 2 +- test/bytecode_2.4/04_comp_for.pyc | Bin 0 -> 366 bytes test/bytecode_2.6/04_comp_for.pyc | Bin 0 -> 357 bytes test/simple_source/bug26/04_comp_for.py | 4 ++++ uncompyle6/semantics/pysource.py | 9 ++++++++- 5 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/bytecode_2.4/04_comp_for.pyc create mode 100644 test/bytecode_2.6/04_comp_for.pyc create mode 100644 test/simple_source/bug26/04_comp_for.py 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 0000000000000000000000000000000000000000..48d75b2e01abba0f01d2bcbc010a11653809d7e9 GIT binary patch literal 366 zcmYL^&q~8U5XQg6TCmVd1rK_Wp5j3(BA!G&cveWkh!R4ZPTD|{O?Rh|f<5We`8Ym- zGmGG|^V`{-f8W+W!@=wGcar08?aBEd=8gpm;0qwx0g4chp8?)NECNiUP{Mg2&;m8> z;LZfy7#~1-f?bGi1eUsVfL#FY;bnb@WZg$1ou`qOKSldO9tqyfhHK;aykxSoc||E} zhV$HdcAgaJz*r2i_cSfis|Sz8b7kFDlsU7pIZfu9<<-sP@;b{+-DZWc7wwjhB<*%d zjSORBPpNAyIaiwIuBQzYeGEmR&JgkPMpeP8*YJw0_wv=OZ2V8+0}1@Ai2c7**}X3n F2fsWmKllIu literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..3b524d505763162d19d1dd26adce9d14325eec5e GIT binary patch literal 357 zcmb7-KWhR(5XIkK{tyjTb|F>L94S;nNF^bKwH87y1muW&b1K}q=j|SxpjG^I>HI2w z0%taYb(YN0sUNWcCimDX)NMFmFuBDxfK&KTt2Uz5H6o54hcZ9(QQQO8UMZ9~CxA}RJJxF* zvI8&nfh)Vni;QAxs!~&TTFstcySpF literal 0 HcmV?d00001 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 ), + }) ##########################