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: Detect "continue" inside except
Fixes issue #38. This is a bit hacky. We need a more general "continue" detection.
This commit is contained in:
@@ -32,7 +32,7 @@ from xdis.bytecode import findlinestarts
|
||||
import uncompyle6.scanner as scan
|
||||
|
||||
class Scanner2(scan.Scanner):
|
||||
def __init__(self, version, show_asm=None):
|
||||
def __init__(self, version, show_asm=None, is_pypy=False):
|
||||
scan.Scanner.__init__(self, version, show_asm)
|
||||
self.pop_jump_if = frozenset([self.opc.PJIF, self.opc.PJIT])
|
||||
self.jump_forward = frozenset([self.opc.JUMP_ABSOLUTE, self.opc.JUMP_FORWARD])
|
||||
@@ -164,6 +164,18 @@ class Scanner2(scan.Scanner):
|
||||
elif op in self.opc.hasjrel:
|
||||
pattr = repr(offset + 3 + oparg)
|
||||
elif op in self.opc.hasjabs:
|
||||
if self.version == 2.7 and op == self.opc.JUMP_ABSOLUTE:
|
||||
target = self.get_target(offset)
|
||||
# FIXME: this is a hack to catch stuff like:
|
||||
# for ...
|
||||
# try: ...
|
||||
# except: continue
|
||||
# the "continue" is not on a new line.
|
||||
n = len(tokens)
|
||||
if (n > 2 and
|
||||
tokens[-1].type == 'JUMP_BACK' and
|
||||
self.code[offset+3] == self.opc.END_FINALLY):
|
||||
tokens[-1].type = intern('CONTINUE')
|
||||
pattr = repr(oparg)
|
||||
elif op in self.opc.haslocal:
|
||||
pattr = varnames[oparg]
|
||||
|
Reference in New Issue
Block a user