From 36432c74884bad8ef17f347a5fb41c0f91e12257 Mon Sep 17 00:00:00 2001 From: rocky Date: Tue, 28 Jun 2016 14:36:45 -0400 Subject: [PATCH] Add more come_from_pops --- test/bytecode_2.6/06_return_if.pyc | Bin 0 -> 711 bytes test/simple_source/stmts/06_return_if.py | 11 +++++++++++ uncompyle6/parsers/parse26.py | 17 ++++++++--------- 3 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 test/bytecode_2.6/06_return_if.pyc create mode 100644 test/simple_source/stmts/06_return_if.py diff --git a/test/bytecode_2.6/06_return_if.pyc b/test/bytecode_2.6/06_return_if.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3564f028b74e688ce4dba2ddebf6f0195aad808c GIT binary patch literal 711 zcmbVK%}T>S5S~q2wUz3jFCcgc2v#qiMEs#gdq@SrOGuNgrX<<2J2@2MMf++#fUn{c zIN!F|vklCbnawvd-%R%Vr{C*++2@otPayAGF*gv%h*pA%R*GK431||w=p$xR12Vw9p4r2NT&c#+d6FFv660JE$$jZ-ATK%a=YkwDW%#-}24 zMv5hF`B-ulCXiC{tqEuzkm-<;c%mvL)BwDXO#{p~_B-NzabGnj%$6}RFBh7zr#m^x zr#0)5wZ?`}68XJ!#RJ`cn&&2+9)_Ur zHBeo(u7<5d*mDFu5hy#f!SwfuAnBmfYM}jp|>~S7f*qP A)c^nh literal 0 HcmV?d00001 diff --git a/test/simple_source/stmts/06_return_if.py b/test/simple_source/stmts/06_return_if.py new file mode 100644 index 00000000..6d418479 --- /dev/null +++ b/test/simple_source/stmts/06_return_if.py @@ -0,0 +1,11 @@ +# from 2.6.9 Bastion.py +# Should see in 2.6.9: +# return_if_stmt ::= ret_expr RETURN_END_IF come_from_pop + +def Bastion(object, filter = lambda name: name[:1] != '_'): + def get1(name, attribute, MethodType, object=object, filter=filter): + if filter(name): + attribute = getattr(object, name) + if type(attribute) == MethodType: + return attribute + raise AttributeError, name diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index 123bc5a5..155d1983 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -57,15 +57,6 @@ class Python26Parser(Python2Parser): """ - def p_whilestmt(self, args): - """ - whilestmt ::= SETUP_LOOP - testexpr - l_stmts_opt jb_pop - POP_BLOCK _come_from - - """ - def p_misc26(self, args): """ jmp_true ::= JUMP_IF_TRUE POP_TOP @@ -94,6 +85,14 @@ class Python26Parser(Python2Parser): # This is truly weird. 2.7 does this (not including POP_TOP) with # opcode SETUP_WITH setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP + + whilestmt ::= SETUP_LOOP + testexpr + l_stmts_opt jb_pop + POP_BLOCK _come_from + + return_if_stmt ::= ret_expr RETURN_END_IF come_from_pop + """ def p_comp26(self, args):