You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Fix bug in 2.6 tryelse get test_grammar working...
localize grammar rules
This commit is contained in:
@@ -1023,33 +1023,45 @@ class Scanner2(Scanner):
|
||||
pass
|
||||
pass
|
||||
|
||||
# FIXME: All the < 2.7 conditions are is horrible. We need a better way.
|
||||
# FIXME FIXME FIXME
|
||||
# All the conditions are horrible, and I am not sure I
|
||||
# undestand fully what's going l
|
||||
# WeR REALLY REALLY need a better way to handle control flow
|
||||
# Expecially for < 2.7
|
||||
if label is not None and label != -1:
|
||||
# In Python < 2.7, the POP_TOP in:
|
||||
# RETURN_VALUE, POP_TOP
|
||||
# does now start a new statement
|
||||
# Otherwise, we have want to add a "COME_FROM"
|
||||
if not (self.version < 2.7 and
|
||||
code[label] == self.opc.POP_TOP and
|
||||
code[self.prev[label]] == self.opc.RETURN_VALUE):
|
||||
if self.version == 2.7:
|
||||
# FIXME: rocky: I think we need something like this...
|
||||
if label in self.setup_loops:
|
||||
source = self.setup_loops[label]
|
||||
else:
|
||||
source = offset
|
||||
targets[label] = targets.get(label, []) + [source]
|
||||
elif not (code[label] == self.opc.POP_TOP and
|
||||
code[self.prev[label]] == self.opc.RETURN_VALUE):
|
||||
# In Python < 2.7, don't add a COME_FROM, for:
|
||||
# JUMP_FORWARD, END_FINALLY
|
||||
# RETURN_VALUE POP_TOP .. END_FINALLY
|
||||
# or:
|
||||
# JUMP_FORWARD, POP_TOP, END_FINALLY
|
||||
if not (self.version < 2.7 and op == self.opc.JUMP_FORWARD
|
||||
and ((code[offset+3] == self.opc.END_FINALLY)
|
||||
or (code[offset+3] == self.opc.POP_TOP
|
||||
and code[offset+4] == self.opc.END_FINALLY))):
|
||||
|
||||
# RETURN_VALUE POP_TOP .. POP_TOP END_FINALLY
|
||||
skip_come_from = False
|
||||
if self.version <= 2.1:
|
||||
skip_come_from = (code[offset+3] == self.opc.END_FINALLY or
|
||||
(code[offset+3] == self.opc.POP_TOP
|
||||
and code[offset+4] == self.opc.END_FINALLY))
|
||||
else:
|
||||
skip_come_from = (code[offset+3] == self.opc.END_FINALLY or
|
||||
(op != self.opc.JUMP_FORWARD
|
||||
and code[offset+3] == self.opc.POP_TOP
|
||||
and code[offset+4] == self.opc.END_FINALLY))
|
||||
if not skip_come_from:
|
||||
# FIXME: rocky: I think we need something like this...
|
||||
if offset not in set(self.ignore_if) or self.version == 2.7:
|
||||
if offset not in set(self.ignore_if):
|
||||
if label in self.setup_loops:
|
||||
source = self.setup_loops[label]
|
||||
else:
|
||||
source = offset
|
||||
targets[label] = targets.get(label, []) + [source]
|
||||
pass
|
||||
pass
|
||||
|
||||
pass
|
||||
pass
|
||||
elif op == self.opc.END_FINALLY and offset in self.fixed_jumps and self.version == 2.7:
|
||||
|
Reference in New Issue
Block a user