Merge branch 'master' into pypy

Conflicts:
	uncompyle6/scanners/scanner2.py
This commit is contained in:
rocky
2016-07-23 10:43:59 -04:00
5 changed files with 27 additions and 6 deletions

Binary file not shown.

View File

@@ -0,0 +1,11 @@
# Issue #38 in Python 2.7
# Problem is distinguishing 'continue' from 'jump_back'
# in assembly instructions.
# Here, we hack looking for two jump backs
# followed by the end of the except. This
# is a big hack.
for a in [__name__]:
try:len(a)
except:continue

View File

@@ -27,7 +27,6 @@ from collections import namedtuple
from array import array
from xdis.code import iscode
from xdis.bytecode import findlinestarts
import uncompyle6.scanner as scan
@@ -164,6 +163,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]
@@ -271,7 +282,7 @@ class Scanner2(scan.Scanner):
# linestarts is a tuple of (offset, line number).
# Turn that in a has that we can index
self.linestarts = list(findlinestarts(co))
self.linestarts = list(self.opc.findlinestarts(co))
self.linestartoffsets = {}
for offset, lineno in self.linestarts:
self.linestartoffsets[offset] = lineno

View File

@@ -14,7 +14,6 @@ from uncompyle6 import PYTHON3
if PYTHON3:
intern = sys.intern
from xdis.bytecode import findlinestarts
import uncompyle6.scanners.scanner2 as scan
# bytecode verification, verify(), uses JUMP_OPs from here
@@ -103,7 +102,7 @@ class Scanner26(scan.Scanner2):
self.build_prev_op(n)
# linestarts contains block code adresses (addr,block)
self.linestarts = list(findlinestarts(co))
self.linestarts = list(self.opc.findlinestarts(co))
# class and names
if classname:

View File

@@ -26,7 +26,7 @@ from collections import namedtuple
from array import array
from xdis.code import iscode
from xdis.bytecode import Bytecode, findlinestarts
from xdis.bytecode import Bytecode
from uncompyle6.scanner import Token, parse_fn_counts
# Get all the opcodes into globals
@@ -300,7 +300,7 @@ class Scanner3(scan.Scanner):
"""
# Offset: lineno pairs, only for offsets which start line.
# Locally we use list for more convenient iteration using indices
linestarts = list(findlinestarts(code_obj))
linestarts = list(self.opc.findlinestarts(code_obj))
self.linestarts = dict(linestarts)
# Plain set with offsets of first ops on line
self.linestart_offsets = set(a for (a, _) in linestarts)