You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
2.7 for .. try-else bug
This commit is contained in:
BIN
test/bytecode_2.7/05_for_try_else.pyc
Normal file
BIN
test/bytecode_2.7/05_for_try_else.pyc
Normal file
Binary file not shown.
20
test/simple_source/bug27+/05_for_try_else.py
Normal file
20
test/simple_source/bug27+/05_for_try_else.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# Bug found in 2.7 test_itertools.py
|
||||
def test_iziplongest(self):
|
||||
|
||||
# Having a for loop seems important
|
||||
for args in ['abc']:
|
||||
self.assertEqual(1, 2)
|
||||
|
||||
pass # Having this seems important
|
||||
|
||||
# The bug was the except jumping back
|
||||
# to the beginning of this for loop
|
||||
for stmt in [
|
||||
"izip_longest('abc', fv=1)",
|
||||
]:
|
||||
try:
|
||||
eval(stmt)
|
||||
except TypeError:
|
||||
pass
|
||||
else:
|
||||
self.fail()
|
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2016-2017 Rocky Bernstein
|
||||
# Copyright (c) 2016-2018 Rocky Bernstein
|
||||
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
||||
# Copyright (c) 2000-2002 by hartmut Goebel <hartmut@goebel.noris.de>
|
||||
|
||||
@@ -17,9 +17,11 @@ class Python27Parser(Python2Parser):
|
||||
list_for ::= expr for_iter store list_iter JUMP_BACK
|
||||
list_comp ::= BUILD_LIST_0 list_iter
|
||||
lc_body ::= expr LIST_APPEND
|
||||
for_iter ::= GET_ITER COME_FROM FOR_ITER
|
||||
|
||||
stmt ::= setcomp_func
|
||||
|
||||
|
||||
# Dictionary and set comprehensions were added in Python 2.7
|
||||
expr ::= dict_comp
|
||||
dict_comp ::= LOAD_DICTCOMP MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1
|
||||
@@ -53,6 +55,9 @@ class Python27Parser(Python2Parser):
|
||||
tryelsestmtl ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||
except_handler else_suitel JUMP_BACK COME_FROM
|
||||
|
||||
tryelsestmtl ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
||||
except_handler else_suitel
|
||||
|
||||
except_stmt ::= except_cond2 except_suite
|
||||
|
||||
except_cond1 ::= DUP_TOP expr COMPARE_OP
|
||||
@@ -60,6 +65,9 @@ class Python27Parser(Python2Parser):
|
||||
|
||||
except_cond2 ::= DUP_TOP expr COMPARE_OP
|
||||
jmp_false POP_TOP store POP_TOP
|
||||
|
||||
for_block ::= l_stmts_opt JUMP_BACK
|
||||
|
||||
"""
|
||||
|
||||
def p_jump27(self, args):
|
||||
|
Reference in New Issue
Block a user