From 28ef04d1414e8eb4eaef538d4f2bf1afeb42404a Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 15 Feb 2020 05:10:11 -0500 Subject: [PATCH] More bugs found via sre_parse.py decompilation --- test/bytecode_2.3/08_while1_if_continue.pyc | Bin 637 -> 1294 bytes test/bytecode_2.4/08_while1_if_continue.pyc | Bin 491 -> 960 bytes test/bytecode_2.6/08_while1_if_continue.pyc | Bin 545 -> 1061 bytes .../looping/08_while1_if_continue.py | 29 +++++++++++++++++- uncompyle6/parsers/parse23.py | 2 ++ uncompyle6/parsers/parse24.py | 2 ++ 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/test/bytecode_2.3/08_while1_if_continue.pyc b/test/bytecode_2.3/08_while1_if_continue.pyc index a2d50a562ce933e36c650dbf105098f8811f43cb..4b236806510406b57ca1de0ddec07602a81134e9 100644 GIT binary patch literal 1294 zcmb`G+lmuG5QeK}a@Zs)iyK5x5fxD_pHV`SBPV9z=IG&hk7RM3nD-*6tI@ukpn@=;@WQ)^zlI>25VrKG>yL%7g z&nM!%ADc;>6nSOx(`;wyL;F7l8PK;GJ&fC`!(q^b_6t{nGiMBXIg7v z$+s8y9$E0i{ZYZ84EtIp_fj!D_522&hG6v6+-+(@)M|+&MMz*F0-sz8VP%|E! Wd!e;p7kd<7@@$2y)9Y+>Hh%;ABl1E3 delta 116 zcmeC<`paTw{fU?B?m@S>WCkc;1kw&bTr378QWzLo7#N~}3`Q`6ks*bNAy|WXqsMYa wM&8LE7{!$RG?+lDIe7UZ06P^HV*mgE diff --git a/test/bytecode_2.4/08_while1_if_continue.pyc b/test/bytecode_2.4/08_while1_if_continue.pyc index 9cf18747a4ecea19eb4dddcbd5280714b13464b1..69e9e9051b034401fa73b10934241e34ca29a435 100644 GIT binary patch literal 960 zcmaKq&uZI15XNWa*oy7AG$n)*d}#wgrNwCzD7mH3LvAK02SX1PjwB}wj%0Z^RDtAD z`Y3&pK2o2c-?!^OG%2;&(YL#^v-8`To8P_8&tGR>Q(62JzMn8m1e1yU5cvY3oKTVl zP6U!QoM=e4As0~-&MA*B$7hCk15>}2dy(>mD66ClMO6){`l1RY3gIs>RU?WhfcH={ zfRlEEA@b?OZbBrLPFO_!h${NEPDW4N_ju!3!PDK1AJ@dtmfL)jc_{@EsB0 zyU0H|cox_qmk~obIgXudVeXT)d^}^vHeVyfd<;vUWHz3g{25(nmMJpPPLR^=uOx?9 zsL#aW$zS;=-$kxlEZ{?cjCXv-)mvYIdYeg=O;P970JXswp~MfU(W)-EYEc(W=}2Pc z>_HsOwKfi}_Pb0x4r$sn9hk>#-1TfnyO5?2vxEy>9a^e|IuJBmqVoP#Jx(#HPaNty zj|yVXS-*74#A2VZJbMKH=-Q7h__XI3dyVCDc57>x|8pE4AcEO}S#z`&9o1Ar|1vHj f8#?aNu`8H`{CBSQ)kL$C((Mvr(# rOnbp}qf}C6cXIKv) diff --git a/test/bytecode_2.6/08_while1_if_continue.pyc b/test/bytecode_2.6/08_while1_if_continue.pyc index 7d47699dfb0202e586db2b744b23d1251c780dd2..34a3b332678c0edc059369d4ccac3c46b9b4eee5 100644 GIT binary patch literal 1061 zcmb`G&u-H|5XNWh{I?2KRaF%N^@5N=RSRtoNT3SD0Zvin-Z)?ddqY=p?KrzpjnrNc zkHVAi2D}PSzc8AW|9}SG$F!ANXH@fgkG>~fI+g3DpQGL}VKB;%5NxSIumHfXXg=Aw3J_|R-Z3(;tcPf1X%mhVx730i0 zm7=*Fbzc&;)CXJQI+#`8Lhf-#x`!?LZ;`%xI3e1Z7M8H?X2#11Cc{_`fg@A4xK|E@p+<(=qMxxYb#;hb#$3Ac@4>+^ycf Wz928pt9((IW6(Ktau^K{=;wN6Ny9eFkk{O_Y5lA}#aj_VXNMT@TVPJ>?G8n-OMurq7hF}fmjUIW7 u8oVG?TtI?>k(rSlh&h=2G?;+gATYrWWNCn8C+9KRP3B?|WCICvasdFMq7Tae diff --git a/test/simple_source/looping/08_while1_if_continue.py b/test/simple_source/looping/08_while1_if_continue.py index eba6ead7..de4dd758 100644 --- a/test/simple_source/looping/08_while1_if_continue.py +++ b/test/simple_source/looping/08_while1_if_continue.py @@ -9,7 +9,8 @@ def readline (self): return # From 2.4.6 sre.py -# Bug in 2.4 and 2.3 was parsing the nested "while 1" with a "break" in it +# Bug has to do with "break" not being recognized +# and is a JUMP_FORWARD. def _parse(a, b, source, state): while 1: if b: @@ -17,3 +18,29 @@ def _parse(a, b, source, state): break else: raise + +def _parse2(source, state): + while 1: + if a: + if b: + while 1: + this = 1 + break + continue + + while 1: + if b: + break + + x = 3 + +# Bug was in 2.3 decompilation +def _parse3(source, state): + while 1: + if a: + if b: + x = 1 + while 1: + if a: + break + raise diff --git a/uncompyle6/parsers/parse23.py b/uncompyle6/parsers/parse23.py index a9f3b5c2..2411cd58 100644 --- a/uncompyle6/parsers/parse23.py +++ b/uncompyle6/parsers/parse23.py @@ -45,6 +45,8 @@ class Python23Parser(Python24Parser): # a "break" inside "l_stmts". while1stmt ::= _while1test l_stmts COME_FROM JUMP_BACK POP_TOP POP_BLOCK COME_FROM + while1stmt ::= _while1test l_stmts JUMP_BACK + POP_TOP POP_BLOCK list_comp ::= BUILD_LIST_0 DUP_TOP LOAD_ATTR store list_iter del_stmt list_for ::= expr for_iter store list_iter JUMP_BACK come_froms POP_TOP JUMP_BACK diff --git a/uncompyle6/parsers/parse24.py b/uncompyle6/parsers/parse24.py index 411daaad..2d3b932c 100644 --- a/uncompyle6/parsers/parse24.py +++ b/uncompyle6/parsers/parse24.py @@ -43,6 +43,8 @@ class Python24Parser(Python25Parser): while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_TOP POP_BLOCK + continue ::= JUMP_BACK JUMP_ABSOLUTE + # Python 2.4 # The following has no "JUMP_BACK" after l_stmts because # l_stmts ends in a "break", "return", or "continue"