mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-04-12 13:03:17 +00:00
parent
b0b67e9f34
commit
6fe8a1d2ba
BIN
test/bytecode_2.4/07_try_except.pyc
Normal file
BIN
test/bytecode_2.4/07_try_except.pyc
Normal file
Binary file not shown.
34
test/simple_source/bug26/07_try_except.py
Normal file
34
test/simple_source/bug26/07_try_except.py
Normal file
@ -0,0 +1,34 @@
|
||||
# Bug portion of Issue #405 https://github.com/rocky/python-uncompyle6/issues/405
|
||||
# Bug was detecting if/else as the last item in a "try: .. except" block.
|
||||
class Saveframe(object):
|
||||
"""A saveframe. Use the classmethod from_scratch to create one."""
|
||||
|
||||
frame_list = {}
|
||||
|
||||
def frame_dict(self):
|
||||
return
|
||||
|
||||
# Next line is 1477
|
||||
def __setitem__(self, key, item):
|
||||
# Next line is 1481
|
||||
if isinstance(item, Saveframe):
|
||||
try:
|
||||
self.frame_list[key] = item
|
||||
except TypeError:
|
||||
if key in (self.frame_dict()):
|
||||
dict((frame.name, frame) for frame in self.frame_list)
|
||||
for pos, frame in enumerate(self.frame_list):
|
||||
if frame.name == key:
|
||||
self.frame_list[pos] = item
|
||||
else:
|
||||
raise KeyError(
|
||||
"Saveframe with name '%s' does not exist and "
|
||||
"therefore cannot be written to. Use the add_saveframe method to add new saveframes."
|
||||
% key
|
||||
)
|
||||
# Next line is 1498
|
||||
raise ValueError("You can only assign an entry to a saveframe splice.")
|
||||
|
||||
|
||||
x = Saveframe()
|
||||
x.__setitem__("foo", 5)
|
@ -130,6 +130,10 @@ class Python26Parser(Python2Parser):
|
||||
# Semantic actions want else_suitel to be at index 3
|
||||
ifelsestmtl ::= testexpr c_stmts_opt cf_jb_cf_pop else_suitel
|
||||
ifelsestmtc ::= testexpr c_stmts_opt ja_cf_pop else_suitec
|
||||
ifelsestmt ::= testexpr stmts_opt ja_cf_pop else_suite
|
||||
|
||||
# The last except of a "try: ... except" can do this...
|
||||
except_suite ::= stmts_opt COME_FROM JUMP_ABSOLUTE POP_TOP
|
||||
|
||||
# Semantic actions want suite_stmts_opt to be at index 3
|
||||
with ::= expr setupwith SETUP_FINALLY suite_stmts_opt
|
||||
|
Loading…
x
Reference in New Issue
Block a user