From 701d2af54e5796357140d6bcd3dcbf506f3659fa Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 15 Apr 2019 23:13:45 -0400 Subject: [PATCH] Improve Python 2.7 generator handling --- test/bytecode_2.7_run/02_ifelse_comprehension.pyc | Bin 0 -> 986 bytes uncompyle6/parsers/parse27.py | 1 - uncompyle6/semantics/pysource.py | 4 ++-- 3 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 test/bytecode_2.7_run/02_ifelse_comprehension.pyc diff --git a/test/bytecode_2.7_run/02_ifelse_comprehension.pyc b/test/bytecode_2.7_run/02_ifelse_comprehension.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f33fe50e093456b72370d8e32e1366c50704ffb3 GIT binary patch literal 986 zcmbVJO>fgc5Pj=S(x#%^IB`Nk$XwF2IU!XQEg#1m9K->EqF`@=MQo?LYpIC#LQ#_+ z1QP#?Kfs%HLJ@F^<#{{1J8$OAtp2&bcXRsvZHo1`!}Tf6{UBt(SKtjD6&wXaKf+82 z8g3(G8d(e19YLP+{}{oY!E1ck#Aj{H7}*Y#)*lodQUzpy5I_HiXj=aeL#=hihWKqw z%sLpw(nZ=Kh_z{&<{lF+BP@ZX!jg{0lxh@i0M9GnTH!g3|0s?aJxmo*Jh1`I^$Co8 z_Xt-CE5JU$O2OWjVVyt3DnhBT3N5`>=N!%^S1vk+F##dBmz2G}mkN2@A_jL7&eOwY zIckIA8cg;)0?yk?AFJkw_0s3t=lUf8A~&(o11; z;Z4cMV|4*2t?or({F^6uCU<*;-)}VvT@0IEM9@5UzS)Unw%ur@k8N~Gl4(`#3td`; z$^~ynk&CurEK^BjmdPDL7~v~h8-JI(Q|FBJe2o{@R@O`C%L$+AR$1`2k+;iS$3>OZ Rb8`{~CkNe~uI{TR>KDuXvKIgV literal 0 HcmV?d00001 diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index c960eb21..3704eecd 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -41,7 +41,6 @@ class Python27Parser(Python2Parser): comp_body ::= set_comp_body comp_for ::= expr for_iter store comp_iter JUMP_BACK - comp_iter ::= comp_if comp_iter ::= comp_body dict_comp_body ::= expr expr MAP_ADD diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 27486200..c0262082 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2018 by Rocky Bernstein +# Copyright (c) 2015-2019 by Rocky Bernstein # Copyright (c) 2005 by Dan Pascu # Copyright (c) 2000-2002 by hartmut Goebel # Copyright (c) 1999 John Aycock @@ -943,7 +943,7 @@ class SourceWalker(GenericASTTraversal, object): # FIXME: clean this up if self.version >= 3.0 and node == 'dict_comp': cn = node[1] - elif self.version < 2.7 and node == 'generator_exp': + elif self.version <= 2.7 and node == 'generator_exp': if node[0] == 'LOAD_GENEXPR': cn = node[0] elif node[0] == 'load_closure':