Another 3.x bug involving jumps

This commit is contained in:
rocky 2016-06-19 17:47:43 -04:00
parent 109d99bc62
commit bd809dc08b
3 changed files with 24 additions and 4 deletions

Binary file not shown.

View File

@ -0,0 +1,19 @@
# Python 3.4 bug found from tempfile.py
def _get_default_tempdir(dirlist, fd):
for dir in dirlist:
for seq in range(100):
try:
try:
try:
with open(fd, 'wb', closefd=False) as fp:
fp.write(b'blat')
finally:
seq += 1
finally:
seq += 10
return dir
except RuntimeError:
pass
except OSError:
break # no point trying more names in this directory
raise RuntimeError

View File

@ -265,8 +265,11 @@ class Python3Parser(PythonParser):
except_stmt ::= except_pop_except
# Python3 introduced POP_EXCEPT
except_suite ::= c_stmts_opt POP_EXCEPT JUMP_FORWARD
except_suite ::= c_stmts_opt POP_EXCEPT jmp_abs
except_suite ::= c_stmts_opt POP_EXCEPT jump_except
jump_except ::= JUMP_ABSOLUTE
jump_except ::= JUMP_BACK
jump_except ::= JUMP_FORWARD
jump_except ::= CONTINUE
# This is used in Python 3 in
# "except ... as e" to remove 'e' after the c_stmts_opt finishes
@ -287,11 +290,9 @@ class Python3Parser(PythonParser):
except ::= POP_TOP POP_TOP POP_TOP c_stmts_opt POP_EXCEPT _jump
except ::= POP_TOP POP_TOP POP_TOP return_stmts
jmp_abs ::= JUMP_ABSOLUTE
jmp_abs ::= JUMP_BACK
withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM
WITH_CLEANUP END_FINALLY