Another 3.6 control-flow bug...

and add source to some previous bytecode tests
This commit is contained in:
rocky
2018-03-31 19:28:35 -04:00
parent 64ffa5f6ab
commit 535df1592e
6 changed files with 62 additions and 0 deletions

Binary file not shown.

View 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()

View 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

View 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()

View 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

View File

@@ -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