You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Allow Python 3.5 to decomplyle other versions. No Python 3.5
bytecode support just yet though.
This commit is contained in:
2
Makefile
2
Makefile
@@ -24,7 +24,7 @@ check:
|
|||||||
$(MAKE) check-$$PYTHON_VERSION
|
$(MAKE) check-$$PYTHON_VERSION
|
||||||
|
|
||||||
#: Tests for Python 2.7, 3.3 and 3.4
|
#: Tests for Python 2.7, 3.3 and 3.4
|
||||||
check-2.7 check-3.3 check-3.4: pytest
|
check-2.7 check-3.3 check-3.4 check-3.5: pytest
|
||||||
$(MAKE) -C test $@
|
$(MAKE) -C test $@
|
||||||
|
|
||||||
#:Tests for Python 2.6 (doesn't have pytest)
|
#:Tests for Python 2.6 (doesn't have pytest)
|
||||||
|
@@ -26,6 +26,9 @@ check-2.6 check-2.7: check-bytecode check-2.7-ok
|
|||||||
check-3.3: check-bytecode
|
check-3.3: check-bytecode
|
||||||
$(PYTHON) test_pythonlib.py --bytecode-3.3 --verify $(COMPILE)
|
$(PYTHON) test_pythonlib.py --bytecode-3.3 --verify $(COMPILE)
|
||||||
|
|
||||||
|
#: Run working tests from Python 3.5
|
||||||
|
check-3.5: check-bytecode
|
||||||
|
|
||||||
#: Run working tests from Python 3.4
|
#: Run working tests from Python 3.4
|
||||||
check-3.4: check-bytecode check-2.7-ok
|
check-3.4: check-bytecode check-2.7-ok
|
||||||
|
|
||||||
|
@@ -42,8 +42,8 @@ PYTHON_VERSION_STR = "%s.%s" % (sys.version_info[0], sys.version_info[1])
|
|||||||
sys.setrecursionlimit(5000)
|
sys.setrecursionlimit(5000)
|
||||||
|
|
||||||
def check_python_version(program):
|
def check_python_version(program):
|
||||||
if not (sys.version_info[0:2] in ((2, 6), (2, 7), (3, 2), (3, 3), (3, 4))):
|
if not (sys.version_info[0:2] in ((2, 6), (2, 7), (3, 2), (3, 3), (3, 4), (3, 5))):
|
||||||
print('Error: %s requires Python 2.6, 2.7, 3.2, 3.3, or 3.4' % program,
|
print('Error: %s requires Python 2.6, 2.7, 3.2, 3.3, 3.4 or 3.5' % program,
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
return
|
return
|
||||||
|
@@ -18,7 +18,7 @@ want to run on Python 2.7.
|
|||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import inspect, os, sys
|
import os, sys
|
||||||
|
|
||||||
import uncompyle6
|
import uncompyle6
|
||||||
from uncompyle6.code import iscode
|
from uncompyle6.code import iscode
|
||||||
|
@@ -77,9 +77,9 @@ def load_module(filename, code_objects={}):
|
|||||||
else:
|
else:
|
||||||
raise ImportError("Bad magic number: '%s'" % magic)
|
raise ImportError("Bad magic number: '%s'" % magic)
|
||||||
|
|
||||||
if not (2.5 <= version <= 2.7) and not (3.2 <= version <= 3.4):
|
if not (2.5 <= version <= 2.7) and not (3.2 <= version <= 3.5):
|
||||||
raise ImportError("This is a Python %s file! Only "
|
raise ImportError("This is a Python %s file! Only "
|
||||||
"Python 2.5 to 2.7 and 3.2 to 3.4 files are supported."
|
"Python 2.5 to 2.7 and 3.2 to 3.5 files are supported."
|
||||||
% version)
|
% version)
|
||||||
|
|
||||||
# print version
|
# print version
|
||||||
@@ -110,7 +110,8 @@ if __name__ == '__main__':
|
|||||||
co = load_file(__file__)
|
co = load_file(__file__)
|
||||||
obj_path = check_object_path(__file__)
|
obj_path = check_object_path(__file__)
|
||||||
version, timestamp, magic_int, co2 = load_module(obj_path)
|
version, timestamp, magic_int, co2 = load_module(obj_path)
|
||||||
print("version ", version, "magic int", magic_int)
|
print("version", version, "magic int", magic_int)
|
||||||
import datetime
|
import datetime
|
||||||
print(datetime.datetime.fromtimestamp(timestamp))
|
print(datetime.datetime.fromtimestamp(timestamp))
|
||||||
assert co == co2
|
if version < 3.5:
|
||||||
|
assert co == co2
|
||||||
|
@@ -87,7 +87,7 @@ versions = {
|
|||||||
__build_magic(3290): '3.4', # 3.4a4 3290 (changes to __qualname__ computation)
|
__build_magic(3290): '3.4', # 3.4a4 3290 (changes to __qualname__ computation)
|
||||||
__build_magic(3300): '3.4', # 3.4a4 3300 (more changes to __qualname__ computation)
|
__build_magic(3300): '3.4', # 3.4a4 3300 (more changes to __qualname__ computation)
|
||||||
__build_magic(3310): '3.4', # 3.4rc2 3310 (alter __qualname__ computation)
|
__build_magic(3310): '3.4', # 3.4rc2 3310 (alter __qualname__ computation)
|
||||||
|
__build_magic(3350): '3.5', # 3.5.0
|
||||||
}
|
}
|
||||||
|
|
||||||
magics = __by_version(versions)
|
magics = __by_version(versions)
|
||||||
|
@@ -62,7 +62,7 @@ class Scanner(object):
|
|||||||
elif version == 3.4:
|
elif version == 3.4:
|
||||||
self.opc = opcode_34
|
self.opc = opcode_34
|
||||||
else:
|
else:
|
||||||
raise TypeError("%i is not a Python version I know about")
|
raise TypeError("%s is not a Python version I know about" % version)
|
||||||
|
|
||||||
# FIXME: This weird Python2 behavior is not Python3
|
# FIXME: This weird Python2 behavior is not Python3
|
||||||
self.resetTokenClass()
|
self.resetTokenClass()
|
||||||
@@ -298,13 +298,13 @@ def get_scanner(version):
|
|||||||
scanner = scan.Scanner25()
|
scanner = scan.Scanner25()
|
||||||
elif version == 3.2:
|
elif version == 3.2:
|
||||||
import uncompyle6.scanners.scanner32 as scan
|
import uncompyle6.scanners.scanner32 as scan
|
||||||
scanner = scan.Scanner32()
|
scanner = scan.Scanner32(version)
|
||||||
elif version == 3.3:
|
elif version == 3.3:
|
||||||
import uncompyle6.scanners.scanner33 as scan
|
import uncompyle6.scanners.scanner33 as scan
|
||||||
scanner = scan.Scanner33()
|
scanner = scan.Scanner33(version)
|
||||||
elif version == 3.4:
|
elif version == 3.4:
|
||||||
import uncompyle6.scanners.scanner34 as scan
|
import uncompyle6.scanners.scanner34 as scan
|
||||||
scanner = scan.Scanner34()
|
scanner = scan.Scanner34(version)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Unsupported Python version %d" % version)
|
raise RuntimeError("Unsupported Python version %d" % version)
|
||||||
return scanner
|
return scanner
|
||||||
|
@@ -15,7 +15,7 @@ from array import array
|
|||||||
|
|
||||||
from uncompyle6.code import iscode
|
from uncompyle6.code import iscode
|
||||||
from uncompyle6.scanner import Token
|
from uncompyle6.scanner import Token
|
||||||
from uncompyle6 import PYTHON_VERSION, PYTHON3
|
from uncompyle6 import PYTHON3
|
||||||
|
|
||||||
|
|
||||||
# Get all the opcodes into globals
|
# Get all the opcodes into globals
|
||||||
@@ -27,8 +27,8 @@ import uncompyle6.scanner as scan
|
|||||||
|
|
||||||
class Scanner3(scan.Scanner):
|
class Scanner3(scan.Scanner):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, version):
|
||||||
scan.Scanner.__init__(self, PYTHON_VERSION)
|
scan.Scanner.__init__(self, version)
|
||||||
|
|
||||||
def disassemble_generic(self, co, classname=None, code_objects={}):
|
def disassemble_generic(self, co, classname=None, code_objects={}):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user