You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Python 3.4 if ifelse decompyling now works.
This commit is contained in:
100
test/bytecompile-tests
Executable file
100
test/bytecompile-tests
Executable file
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
compile_tests -- compile test patterns for the decompyle test suite
|
||||
|
||||
This source is part of the decompyle test suite.
|
||||
|
||||
decompyle is a Python byte-code decompiler
|
||||
See http://www.crazy-compilers.com/decompyle/ for
|
||||
for further information
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import py_compile, os, sys, getopt
|
||||
|
||||
work_dir = os.path.dirname(sys.argv[0])
|
||||
src_dir = work_dir
|
||||
|
||||
opts, args = getopt.getopt(sys.argv[1:], 's:w:')
|
||||
|
||||
for opt, val in opts:
|
||||
if opt == '-s':
|
||||
src_dir = val
|
||||
if opt == '-w':
|
||||
work_dir = val
|
||||
else:
|
||||
raise "Unknown Option '%s'" % opt
|
||||
if args:
|
||||
raise 'This tool does not want any arguments'
|
||||
|
||||
print("Using files in dir %s" % src_dir)
|
||||
print( "Compiling into dir %s" % work_dir)
|
||||
|
||||
tests = {}
|
||||
|
||||
tests['1.5'] = ["class", "del", "docstring", 'empty', "exec",
|
||||
"exceptions", "expressions", "functions", "global",
|
||||
"globals", "import", "integers", "lambda", "loops",
|
||||
"misc", "nested_elif", "prettyprint", "print",
|
||||
'single_stmt', "slices", "tuple_params", 'tuples']
|
||||
|
||||
tests['1.6'] = ["applyEquiv", ] + tests['1.5']
|
||||
|
||||
tests['2.0'] = ["augmentedAssign", "extendedImport", "extendedPrint",
|
||||
"import_as", "listComprehensions", 'print_to'] + \
|
||||
tests['1.6'] # [ "--extendedarg", ]
|
||||
|
||||
tests['2.1'] = ['loops2', 'nested_scopes'] + tests['2.0']
|
||||
|
||||
tests['2.2'] = ['divide_future', 'divide_no_future', 'iterators',
|
||||
'yield'] + tests['2.1']
|
||||
|
||||
tests['2.3'] = tests['2.2']
|
||||
tests['2.5'] = tests['2.3']
|
||||
tests['2.6'] = tests['2.5']
|
||||
# tests['2.7'] = ['mine'] + tests['2.6']
|
||||
tests['2.7'] = [
|
||||
'simple-source/branching/ifelse',
|
||||
'simple-source/branching/if'
|
||||
# 'simple-source/call_arguments/keyword',
|
||||
# 'simple-source/call_arguments/positional'
|
||||
]
|
||||
|
||||
tests['3.4'] = [
|
||||
# 'simple-source/branching/ifelse',
|
||||
# 'simple-source/branching/if'
|
||||
# 'simple-source/call_arguments/keyword',
|
||||
# 'simple-source/call_arguments/positional'
|
||||
'simple-source/looping/for',
|
||||
'simple-source/looping/while'
|
||||
]
|
||||
|
||||
total_tests = len(tests['2.7'])
|
||||
#tests['2.2'].sort(); print tests['2.2']
|
||||
|
||||
extension = '.py' + (__debug__ and 'c' or 'o')
|
||||
|
||||
def compile(filename, target_dir):
|
||||
sfile = os.path.join(src_dir, '%s.py' % filename)
|
||||
cfile = os.path.join(target_dir, '%s%s'
|
||||
% (os.path.basename(filename), extension) )
|
||||
py_compile.compile(sfile, cfile=cfile)
|
||||
|
||||
def compile_for_version(version):
|
||||
target_dir = os.path.join(work_dir, 'bytecode_' + version)
|
||||
if not os.path.exists(target_dir):
|
||||
os.mkdir(target_dir)
|
||||
for filename in tests[version]:
|
||||
compile(filename, target_dir)
|
||||
|
||||
try:
|
||||
version = '%i.%i' % sys.version_info[:2]
|
||||
except AttributeError:
|
||||
version = sys.version[:3]
|
||||
|
||||
print('Compiling test files for Python', version)
|
||||
# print('(%i/%i files)' % (len(tests[version]), total_tests))
|
||||
print('%i files' % len(tests[version]))
|
||||
compile_for_version(version)
|
||||
print('Done.')
|
Reference in New Issue
Block a user