Skip to content

Commit 389fc23

Browse files
committed
3.6 bug related to large whilestmt
1 parent 7787166 commit 389fc23

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed
1.09 KB
Binary file not shown.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# From https://github.com/rocky/python-uncompyle6/issues/420
2+
# Related to EXTENDED_ARG in whilestmt
3+
ERRPR_CODE_DEFINE = {} # Remove this and things works
4+
5+
try:
6+
print()
7+
except Exception:
8+
var1 = 0
9+
var2 = 1
10+
if var1 or var2:
11+
times = 1
12+
while times != False and self.scanner.is_open():
13+
try:
14+
try:
15+
print()
16+
except Exception:
17+
print()
18+
19+
out = 0
20+
count = 1
21+
if out == 1:
22+
break
23+
elif out == 2:
24+
count += 1
25+
if times == 3:
26+
self.func.emit({})
27+
break
28+
else:
29+
continue
30+
if out == 3 or out == b"":
31+
if self.times == 3:
32+
break
33+
count += 1
34+
if count == 3:
35+
count = 0
36+
if out == 4:
37+
self.func.emit(ERRPR_CODE_DEFINE.ReceiedError())
38+
else:
39+
print()
40+
break
41+
continue
42+
else:
43+
count = 0
44+
except Exception:
45+
print("upper exception")
46+
else:
47+
try:
48+
print("jump forward")
49+
while True:
50+
out = self.func.read(count)
51+
if out == b"":
52+
self.func.emit(ERRPR_CODE_DEFINE.ReceiedError())
53+
break
54+
continue
55+
imagedata = out[0]
56+
if imagedata == b"\x05":
57+
self.func.emit(INFORMATION.UnsupportedImage())
58+
break
59+
continue
60+
if imagedata == b"\x15":
61+
self.func.emit(INFORMATION.NoneImage())
62+
break
63+
continue
64+
if out[1] == False:
65+
start_index = imagedata.find(b"BM6")
66+
self.func.emit(imagedata[start_index:], False)
67+
continue
68+
(imagedata, all_code) = imagedata
69+
self.func.emit({})
70+
self.func.emit({})
71+
self.func.emit({}) # remove {} and this works
72+
break
73+
except Exception:
74+
pass

uncompyle6/parsers/parse36.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def p_36_misc(self, args):
5353
for_block ::= l_stmts_opt come_from_loops JUMP_BACK
5454
come_from_loops ::= COME_FROM_LOOP*
5555
56+
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt
57+
JUMP_BACK come_froms POP_BLOCK
5658
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt
5759
JUMP_BACK come_froms POP_BLOCK COME_FROM_LOOP
5860
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt

0 commit comments

Comments
 (0)