File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Bug portion of Issue #405 https://github.com/rocky/python-uncompyle6/issues/405
2
+ # Bug was detecting if/else as the last item in a "try: .. except" block.
3
+ class Saveframe (object ):
4
+ """A saveframe. Use the classmethod from_scratch to create one."""
5
+
6
+ frame_list = {}
7
+
8
+ def frame_dict (self ):
9
+ return
10
+
11
+ # Next line is 1477
12
+ def __setitem__ (self , key , item ):
13
+ # Next line is 1481
14
+ if isinstance (item , Saveframe ):
15
+ try :
16
+ self .frame_list [key ] = item
17
+ except TypeError :
18
+ if key in (self .frame_dict ()):
19
+ dict ((frame .name , frame ) for frame in self .frame_list )
20
+ for pos , frame in enumerate (self .frame_list ):
21
+ if frame .name == key :
22
+ self .frame_list [pos ] = item
23
+ else :
24
+ raise KeyError (
25
+ "Saveframe with name '%s' does not exist and "
26
+ "therefore cannot be written to. Use the add_saveframe method to add new saveframes."
27
+ % key
28
+ )
29
+ # Next line is 1498
30
+ raise ValueError ("You can only assign an entry to a saveframe splice." )
31
+
32
+
33
+ x = Saveframe ()
34
+ x .__setitem__ ("foo" , 5 )
Original file line number Diff line number Diff line change @@ -130,6 +130,10 @@ def p_stmt26(self, args):
130
130
# Semantic actions want else_suitel to be at index 3
131
131
ifelsestmtl ::= testexpr c_stmts_opt cf_jb_cf_pop else_suitel
132
132
ifelsestmtc ::= testexpr c_stmts_opt ja_cf_pop else_suitec
133
+ ifelsestmt ::= testexpr stmts_opt ja_cf_pop else_suite
134
+
135
+ # The last except of a "try: ... except" can do this...
136
+ except_suite ::= stmts_opt COME_FROM JUMP_ABSOLUTE POP_TOP
133
137
134
138
# Semantic actions want suite_stmts_opt to be at index 3
135
139
with ::= expr setupwith SETUP_FINALLY suite_stmts_opt
You can’t perform that action at this time.
0 commit comments