You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Another 3.6 control-flow bug...
and add source to some previous bytecode tests
This commit is contained in:
BIN
test/bytecode_3.6/05-for-ifelse.pyc
Normal file
BIN
test/bytecode_3.6/05-for-ifelse.pyc
Normal file
Binary file not shown.
18
test/simple_source/bug25/04_try_except_else.py
Normal file
18
test/simple_source/bug25/04_try_except_else.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Bug found in 2.4 test_math.py
|
||||||
|
# Bug was turning last try/except/else into try/else
|
||||||
|
import math
|
||||||
|
def test_exceptions():
|
||||||
|
try:
|
||||||
|
x = math.exp(-1000000000)
|
||||||
|
except:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
x = 1
|
||||||
|
try:
|
||||||
|
x = math.sqrt(-1.0)
|
||||||
|
except ValueError:
|
||||||
|
return x
|
||||||
|
else:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
test_exceptions()
|
12
test/simple_source/bug35/06_try_return.py
Normal file
12
test/simple_source/bug35/06_try_return.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# From 3.6.4 pdb.py
|
||||||
|
# Bug was not having a semantic action for "except_return" tree
|
||||||
|
def do_commands(self, arg):
|
||||||
|
if not arg:
|
||||||
|
bnum = 1
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
bnum = int(arg)
|
||||||
|
except:
|
||||||
|
self.error("Usage:")
|
||||||
|
return
|
||||||
|
self.commands_bnum = bnum
|
13
test/simple_source/bug36/05-for-ifelse.py
Normal file
13
test/simple_source/bug36/05-for-ifelse.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# From 3.6.4 configparser.py
|
||||||
|
# Bug in 3.6 was handling "else" with compound
|
||||||
|
# if. there is no POP_BLOCK and
|
||||||
|
# there are several COME_FROMs before the else
|
||||||
|
def _read(self, fp, a, value, f):
|
||||||
|
for line in fp:
|
||||||
|
for prefix in a:
|
||||||
|
fp()
|
||||||
|
if (value and fp and
|
||||||
|
prefix > 5):
|
||||||
|
f()
|
||||||
|
else:
|
||||||
|
f()
|
16
test/simple_source/exception/04_assert_continue.py
Normal file
16
test/simple_source/exception/04_assert_continue.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Adapted from Python 3.3 idlelib/PyParse.py
|
||||||
|
# Bug is continue flowing back to while messing up the determination
|
||||||
|
# that it is inside an "if".
|
||||||
|
|
||||||
|
# RUNNABLE!
|
||||||
|
def _study1(i, n, ch):
|
||||||
|
while i == 3:
|
||||||
|
i = 4
|
||||||
|
if ch:
|
||||||
|
i = 10
|
||||||
|
assert i < 5
|
||||||
|
continue
|
||||||
|
if n:
|
||||||
|
return n
|
||||||
|
|
||||||
|
assert _study1(3, 4, False) == 4
|
@@ -61,6 +61,9 @@ class Python36Parser(Python35Parser):
|
|||||||
|
|
||||||
except_suite ::= c_stmts_opt COME_FROM POP_EXCEPT jump_except COME_FROM
|
except_suite ::= c_stmts_opt COME_FROM POP_EXCEPT jump_except COME_FROM
|
||||||
|
|
||||||
|
jb_cfs ::= JUMP_BACK come_froms
|
||||||
|
ifelsestmtl ::= testexpr c_stmts_opt jb_cfs else_suitel
|
||||||
|
|
||||||
# In 3.6+, A sequence of statements ending in a RETURN can cause
|
# In 3.6+, A sequence of statements ending in a RETURN can cause
|
||||||
# JUMP_FORWARD END_FINALLY to be omitted from try middle
|
# JUMP_FORWARD END_FINALLY to be omitted from try middle
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user