You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Closer to being able to handle Python 3.4 bytecode. Loading of Python
Python bytecode now works. magics from 3.3 to Python 3.4 has been added. Some Python 3.4 scanner issues have been fixed.
This commit is contained in:
@@ -17,12 +17,12 @@ from uncompyle6.scanner import Token
|
||||
# Get all the opcodes into globals
|
||||
globals().update(dis.opmap)
|
||||
from uncompyle6.opcodes.opcode_27 import *
|
||||
import scanner as scan
|
||||
import uncompyle6.scanner as scan
|
||||
|
||||
|
||||
class Scanner34(scan.Scanner):
|
||||
def __init__(self):
|
||||
self.Token = scan.Scanner.__init__(self, 2.7) # check
|
||||
self.Token = scan.Scanner.__init__(self, 3.4) # check
|
||||
|
||||
def run(self, bytecode):
|
||||
code_object = marshal.loads(bytecode)
|
||||
@@ -60,8 +60,7 @@ class Scanner34(scan.Scanner):
|
||||
op = code[offset]
|
||||
# Create token and fill all the fields we can
|
||||
# w/o touching arguments
|
||||
current_token = Token()
|
||||
current_token.type = dis.opname[op]
|
||||
current_token = Token(dis.opname[op])
|
||||
current_token.offset = offset
|
||||
current_token.linestart = True if offset in self.linestarts else False
|
||||
if op >= dis.HAVE_ARGUMENT:
|
||||
@@ -135,6 +134,16 @@ class Scanner34(scan.Scanner):
|
||||
for _ in range(self.op_size(op)):
|
||||
self.prev_op.append(offset)
|
||||
|
||||
def op_size(self, op):
|
||||
"""
|
||||
Return size of operator with its arguments
|
||||
for given opcode <op>.
|
||||
"""
|
||||
if op < dis.HAVE_ARGUMENT:
|
||||
return 1
|
||||
else:
|
||||
return 3
|
||||
|
||||
def find_jump_targets(self):
|
||||
"""
|
||||
Detect all offsets in a byte code which are jump targets.
|
||||
|
Reference in New Issue
Block a user