From 389fc2360a238deea3c0664e5ebf033c94a3007d Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 13 Jul 2024 21:42:49 -0400 Subject: [PATCH] 3.6 bug related to large whilestmt --- test/bytecode_3.6/09_long_whilestmt.pyc | Bin 0 -> 1120 bytes test/simple_source/bug36/09_long_whilestmt.py | 74 ++++++++++++++++++ uncompyle6/parsers/parse36.py | 2 + 3 files changed, 76 insertions(+) create mode 100644 test/bytecode_3.6/09_long_whilestmt.pyc create mode 100644 test/simple_source/bug36/09_long_whilestmt.py diff --git a/test/bytecode_3.6/09_long_whilestmt.pyc b/test/bytecode_3.6/09_long_whilestmt.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7612eb31e20b1f7f1460b1762342405a4c797951 GIT binary patch literal 1120 zcmZ`%&rcIU6rP!Ge{GkxAXM?h5sVQPg3%CyN=YzKnyLXNCe7M;#Vze@ncYIm(Z-vH zCjJ9ny&KOS`2#%d)r-B#&696-+eS^?$-I5@zHh$w=FO~3O___gKh*s+A>YX#-*xmi zaeB`fAr9fBX94XKN)E_?$yI{@J23}LZBdL-A_$KO$_v1)>{0KsXO7k6%}7g~MM_cph)8y*Rnw?r0@@R%-j|8Ig?$$nF_5Y1vXohcEn5|JK|##BGl zl!>UaGC5zDhUOlS)Admws9GCWFOs@~Bg77IVz;Oyy&phDO2@lFsG9||PkDM$S@+*; zW!!hVi#VAlJO??E4y*b&;^iCDQB@;ePM9J7b%M|Qg=7Eb3EqP~=TFEru89ohpB=Gt zFe|KgOf&k7MwxT37|-#!h!J)5e|}WM0lo}bn7oUPs2|Zij&9R>PL`&I`jHJOn(ZMz zEi#Ouxxz_?2AYdpr`-m%0Non2eaDp-R-@BuFVtOiZYy!6H^xId=jokK_SQ;E1wLJ@ zRLYg=)BUYtb*s3&Qz{1WwsNE&q>E!EZk*ZbUTE(Jao=fy7Z@Hi>p{}1*;0byNyn?Y zZID6C?f5~w=5|oQsCQ&7Frel5+^Rqg91umNToo7!Y{An`%RUBS`!>()l(zRPdyil2 z?3Z}{rS$MHuJS?bXbMl4TnV9zqK*_in&Gwny{h!;=M&QpUGFS=~3W%m~Wnnz8qaiEu#*r*yg%Gij Ir$?Ut21SklmH+?% literal 0 HcmV?d00001 diff --git a/test/simple_source/bug36/09_long_whilestmt.py b/test/simple_source/bug36/09_long_whilestmt.py new file mode 100644 index 00000000..1cf98b6b --- /dev/null +++ b/test/simple_source/bug36/09_long_whilestmt.py @@ -0,0 +1,74 @@ +# From https://github.com/rocky/python-uncompyle6/issues/420 +# Related to EXTENDED_ARG in whilestmt +ERRPR_CODE_DEFINE = {} # Remove this and things works + +try: + print() +except Exception: + var1 = 0 + var2 = 1 + if var1 or var2: + times = 1 + while times != False and self.scanner.is_open(): + try: + try: + print() + except Exception: + print() + + out = 0 + count = 1 + if out == 1: + break + elif out == 2: + count += 1 + if times == 3: + self.func.emit({}) + break + else: + continue + if out == 3 or out == b"": + if self.times == 3: + break + count += 1 + if count == 3: + count = 0 + if out == 4: + self.func.emit(ERRPR_CODE_DEFINE.ReceiedError()) + else: + print() + break + continue + else: + count = 0 + except Exception: + print("upper exception") + else: + try: + print("jump forward") + while True: + out = self.func.read(count) + if out == b"": + self.func.emit(ERRPR_CODE_DEFINE.ReceiedError()) + break + continue + imagedata = out[0] + if imagedata == b"\x05": + self.func.emit(INFORMATION.UnsupportedImage()) + break + continue + if imagedata == b"\x15": + self.func.emit(INFORMATION.NoneImage()) + break + continue + if out[1] == False: + start_index = imagedata.find(b"BM6") + self.func.emit(imagedata[start_index:], False) + continue + (imagedata, all_code) = imagedata + self.func.emit({}) + self.func.emit({}) + self.func.emit({}) # remove {} and this works + break + except Exception: + pass diff --git a/uncompyle6/parsers/parse36.py b/uncompyle6/parsers/parse36.py index a76a3749..09980695 100644 --- a/uncompyle6/parsers/parse36.py +++ b/uncompyle6/parsers/parse36.py @@ -53,6 +53,8 @@ class Python36Parser(Python35Parser): for_block ::= l_stmts_opt come_from_loops JUMP_BACK come_from_loops ::= COME_FROM_LOOP* + whilestmt ::= SETUP_LOOP testexpr l_stmts_opt + JUMP_BACK come_froms POP_BLOCK whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK come_froms POP_BLOCK COME_FROM_LOOP whilestmt ::= SETUP_LOOP testexpr l_stmts_opt