Compare commits

..

33 Commits

Author SHA1 Message Date
rocky
31691b2003 Get ready for release 2.1.2 2015-12-31 11:47:21 -05:00
rocky
09ef875b3e Remove tests we will never use 2015-12-31 11:37:06 -05:00
rocky
0129c3a16e Try travis testing on Python 3.5. Fix up Makefile to avoid pytest on 3.5
for now
2015-12-31 11:19:46 -05:00
rocky
4d5a3bc449 Add a few tests from Python 2.7 standard library 2015-12-31 10:57:59 -05:00
rocky
8d90e33832 Handle Python 3.3 > dotted class names 2015-12-31 10:56:12 -05:00
rocky
0533bbb758 Note Python 3.5 2015-12-30 23:48:27 -05:00
rocky
b82a8b90d5 Allow Python 3.5 to decomplyle other versions. No Python 3.5
bytecode support just yet though.
2015-12-30 23:46:29 -05:00
rocky
d3a32b6877 Show details on parsing assert failures. 2015-12-30 23:17:57 -05:00
rocky
21e51004ae Remove accidental schmutz. Try using pattr on 3.4 to get fn names 2015-12-30 20:18:20 -05:00
rocky
d5b023aec4 Parses another variation of Python3 try/except. Reinstate some tests 2015-12-30 19:05:58 -05:00
rocky
e50bebb7c8 Reinstate list comprehension test. I think we've found/fixed the
initialization bug.
2015-12-30 18:51:22 -05:00
rocky
2e91de8355 Start using our replacement for inspect.iscode 2015-12-30 18:44:27 -05:00
rocky
5bbe2c4a45 Doc changes. 2015-12-30 18:20:50 -05:00
rocky
6ffd2fca90 document GenericASTTraversal.preorder and default. 2015-12-30 17:27:45 -05:00
rocky
b3ede4b64b Walker->SourceWalker Traverser->FragmentsWalker 2015-12-30 17:04:18 -05:00
rocky
1785113045 Tidy parse3 grammer a little 2015-12-30 10:26:07 -05:00
rocky
657eeb7de8 Towards Python3 getting try/except working more often. 2015-12-30 09:46:52 -05:00
rocky
313a8578b3 Fix another cross-version bug: eliminate version-specific library 'dis'
and use corresponding version-indepent routine instead.
2015-12-29 22:23:50 -05:00
rocky
a30f3625ac Fix Python 2 cross deparsing pythond bytecode tuples co_consts,
co_names, co_varnames. Reinstate cross Python 2-3 uncompiling
2015-12-29 22:11:45 -05:00
rocky
e17d94f28f Syntax error typo 2015-12-29 17:35:49 -05:00
rocky
16af79f042 Make sure internObjects is (re)initialized 2015-12-29 17:33:54 -05:00
rocky
116263dd8c inspect.iscode -> hasattr for now until we write a cross-version iscode 2015-12-29 17:05:48 -05:00
rocky
34841abe14 scanner3: Python 2.6 compatibility: change set initializations. Get rid
of * import
opcode_*: only a little of the much-needed larger cleanup
Makefile: remove 3.x bytecode checking from Python 2.x for now. DRY
Makefile a little bit (but more is needed)
2015-12-29 08:30:49 -05:00
rocky
226f3c7e63 Python 2.6.9 compatibility 2015-12-28 23:55:03 -05:00
rocky
f77c4b53c4 Marshal loading of = >python 3.4 from Python < 3.4 2015-12-28 14:56:53 -05:00
rocky
6f0a252693 Add Python3 marshal codes and start to handle cross-version Python code
object types, introducing scan.Code3
2015-12-28 14:17:28 -05:00
rocky
625feb0517 Possibly closer to getting 2.7 to read 3.4 bytecode 2015-12-27 22:24:30 -05:00
rocky
820fdb4771 Fix up Python 2.x's ability to get code from Python 3.x's bytecode 2015-12-27 19:36:02 -05:00
rocky
d774222eb1 defer some tests 2015-12-27 17:11:58 -05:00
rocky
7ec54b15d8 Merge branch 'master' of github.com:rocky/python-uncompyle6
Conflicts:
	README.rst
2015-12-27 16:51:48 -05:00
rocky
7c5b8d803c More tests 2015-12-27 16:50:45 -05:00
rocky
c508413689 3.2 bytecode 2015-12-27 15:19:53 -05:00
rocky
276709cbb9 DRY Python3 scanner code. Some cross version handling fixed.
Some Python 3.2 and 3.3 deparse fixes.
2015-12-27 04:32:46 -05:00
159 changed files with 1189 additions and 67014 deletions

View File

@@ -6,6 +6,7 @@ python:
- '2.6'
- '2.7'
- '3.4'
- '3.5'
install:
- pip install -r requirements-dev.txt

230
ChangeLog
View File

@@ -1,3 +1,217 @@
2015-12-31 rocky <rb@dustyfeet.com>
* __pkginfo__.py: Get ready for release 2.1.2
2015-12-31 rocky <rb@dustyfeet.com>
* test/base_tests/compile_tests,
test/base_tests/python2.7/test_applyEquiv.py,
test/base_tests/python2.7/test_augmentedAssign.py,
test/base_tests/python2.7/test_class.py,
test/base_tests/python2.7/test_del.py,
test/base_tests/python2.7/test_divide_future.py,
test/base_tests/python2.7/test_divide_no_future.py,
test/base_tests/python2.7/test_docstring.py,
test/base_tests/python2.7/test_empty.py,
test/base_tests/python2.7/test_exceptions.py,
test/base_tests/python2.7/test_exec.py,
test/base_tests/python2.7/test_expressions.py,
test/base_tests/python2.7/test_extendedImport.py,
test/base_tests/python2.7/test_extendedPrint.py,
test/base_tests/python2.7/test_extendedarg.py-notyet,
test/base_tests/python2.7/test_functions.py,
test/base_tests/python2.7/test_global.py,
test/base_tests/python2.7/test_globals.py,
test/base_tests/python2.7/test_import.py,
test/base_tests/python2.7/test_import_as.py,
test/base_tests/python2.7/test_integers.py,
test/base_tests/python2.7/test_iterators.py,
test/base_tests/python2.7/test_lambda.py,
test/base_tests/python2.7/test_listComprehensions.py,
test/base_tests/python2.7/test_loops.py,
test/base_tests/python2.7/test_loops2.py,
test/base_tests/python2.7/test_mine.py,
test/base_tests/python2.7/test_misc.py,
test/base_tests/python2.7/test_nested_elif.py,
test/base_tests/python2.7/test_nested_scopes.py,
test/base_tests/python2.7/test_prettyprint.py,
test/base_tests/python2.7/test_print.py,
test/base_tests/python2.7/test_print_to.py,
test/base_tests/python2.7/test_single_stmt.py,
test/base_tests/python2.7/test_slices.py,
test/base_tests/python2.7/test_tuple_params.py-notyet,
test/base_tests/python2.7/test_tuples.py-notyet,
test/base_tests/python2.7/test_yield.py,
test/base_tests/python3.4/__init__.py: Remove tests we will never
use
2015-12-31 rocky <rb@dustyfeet.com>
* .travis.yml, Makefile: Try travis testing on Python 3.5. Fix up
Makefile to avoid pytest on 3.5 for now
2015-12-31 rocky <rb@dustyfeet.com>
* test/ok_lib2.7/dircache.py, test/ok_lib2.7/dis.py: Add a few tests
from Python 2.7 standard library
2015-12-31 rocky <rb@dustyfeet.com>
* test/simple_source/def/05_class.py, uncompyle6/parsers/parse3.py,
uncompyle6/semantics/fragments.py, uncompyle6/semantics/pysource.py:
Handle Python 3.3 > dotted class names
2015-12-30 rocky <rb@dustyfeet.com>
* README.rst: Note Python 3.5
2015-12-30 rocky <rb@dustyfeet.com>
* Makefile, test/Makefile, uncompyle6/__init__.py,
uncompyle6/disas.py, uncompyle6/load.py, uncompyle6/magics.py,
uncompyle6/scanner.py, uncompyle6/scanners/scanner3.py: Allow Python
3.5 to decomplyle other versions. No Python 3.5 bytecode support
just yet though.
2015-12-30 rocky <rb@dustyfeet.com>
* uncompyle6/parser.py, uncompyle6/semantics/fragments.py,
uncompyle6/semantics/pysource.py: Show details on parsing assert
failures.
2015-12-30 rocky <rb@dustyfeet.com>
* uncompyle6/parsers/parse3.py, uncompyle6/semantics/pysource.py:
Remove accidental schmutz. Try using pattr on 3.4 to get fn names
2015-12-30 rocky <rb@dustyfeet.com>
* uncompyle6/parsers/parse3.py: Parses another variation of Python3
try/except. Reinstate some tests
2015-12-30 rocky <rb@dustyfeet.com>
* : Reinstate list comprehension test. I think we've found/fixed the
initialization bug.
2015-12-30 rocky <rb@dustyfeet.com>
* uncompyle6/code.py, uncompyle6/disas.py, uncompyle6/main.py,
uncompyle6/marsh.py, uncompyle6/scanners/scanner27.py,
uncompyle6/scanners/scanner3.py, uncompyle6/scanners/scanner34.py,
uncompyle6/semantics/fragments.py,
uncompyle6/semantics/pysource.py, uncompyle6/verify.py: Start using
our replacement for inspect.iscode
2015-12-30 rocky <rb@dustyfeet.com>
* uncompyle6/parsers/spark.py, uncompyle6/semantics/fragments.py,
uncompyle6/semantics/pysource.py: Doc changes.
2015-12-30 rocky <rb@dustyfeet.com>
* uncompyle6/parsers/spark.py: document GenericASTTraversal.preorder
and default.
2015-12-30 rocky <rb@dustyfeet.com>
* uncompyle6/main.py, uncompyle6/semantics/fragments.py,
uncompyle6/semantics/pysource.py: Walker->SourceWalker
Traverser->FragmentsWalker
2015-12-30 rocky <rb@dustyfeet.com>
* uncompyle6/parsers/parse3.py: Tidy parse3 grammer a little
2015-12-30 rocky <rb@dustyfeet.com>
* test/simple_source/exception/25_try_except.py,
test/test_pythonlib.py, uncompyle6/parsers/parse3.py,
uncompyle6/scanners/scanner27.py, uncompyle6/scanners/scanner3.py,
uncompyle6/scanners/scanner34.py, uncompyle6/semantics/pysource.py:
Towards Python3 getting try/except working more often.
2015-12-29 rocky <rb@dustyfeet.com>
* uncompyle6/scanners/scanner3.py: Fix another cross-version bug:
eliminate version-specific library 'dis' and use corresponding
version-indepent routine instead.
2015-12-29 rocky <rb@dustyfeet.com>
* test/Makefile, uncompyle6/marsh.py: Fix Python 2 cross deparsing
pythond bytecode tuples co_consts, co_names, co_varnames. Reinstate
cross Python 2-3 uncompiling
2015-12-29 rocky <rb@dustyfeet.com>
* uncompyle6/scanners/scanner34.py: Syntax error typo
2015-12-29 rocky <rb@dustyfeet.com>
* uncompyle6/marsh.py: Make sure internObjects is (re)initialized
2015-12-29 rocky <rb@dustyfeet.com>
* uncompyle6/parser.py, uncompyle6/scanners/scanner34.py,
uncompyle6/verify.py: inspect.iscode -> hasattr for now until we
write a cross-version iscode
2015-12-29 rocky <rb@dustyfeet.com>
* README.rst, test/Makefile, uncompyle6/opcodes/opcode_32.py,
uncompyle6/opcodes/opcode_33.py, uncompyle6/opcodes/opcode_34.py,
uncompyle6/scanners/scanner3.py, uncompyle6/scanners/scanner32.py:
scanner3: Python 2.6 compatibility: change set initializations. Get
rid of * import opcode_*: only a little of the much-needed larger
cleanup Makefile: remove 3.x bytecode checking from Python 2.x for
now. DRY Makefile a little bit (but more is needed)
2015-12-28 rocky <rb@dustyfeet.com>
* uncompyle6/scanners/scanner3.py: Python 2.6.9 compatibility
2015-12-28 rocky <rb@dustyfeet.com>
* uncompyle6/main.py, uncompyle6/marsh.py: Marshal loading of =
>python 3.4 from Python < 3.4
2015-12-28 rocky <rb@dustyfeet.com>
* uncompyle6/disas.py, uncompyle6/load.py, uncompyle6/main.py,
uncompyle6/marsh.py, uncompyle6/scanners/scanner3.py,
uncompyle6/semantics/fragments.py, uncompyle6/semantics/pysource.py:
Add Python3 marshal codes and start to handle cross-version Python
code object types, introducing scan.Code3
2015-12-27 rocky <rb@dustyfeet.com>
* uncompyle6/load.py, uncompyle6/marsh.py: Possibly closer to
getting 2.7 to read 3.4 bytecode
2015-12-27 rocky <rb@dustyfeet.com>
* uncompyle6/load.py, uncompyle6/main.py, uncompyle6/marsh.py,
uncompyle6/scanner.py, uncompyle6/scanners/scanner25.py,
uncompyle6/scanners/scanner26.py, uncompyle6/scanners/scanner27.py,
uncompyle6/scanners/scanner3.py, uncompyle6/scanners/scanner32.py,
uncompyle6/scanners/scanner33.py, uncompyle6/scanners/scanner34.py,
uncompyle6/semantics/pysource.py: Fix up Python 2.x's ability to get
code from Python 3.x's bytecode
2015-12-27 rocky <rb@dustyfeet.com>
* test/test_pythonlib.py: defer some tests
2015-12-27 rocky <rb@dustyfeet.com>
* : commit 7c5b8d803c5b76b185ebc8f6e7587fa64ef531e9 Author: rocky
<rb@dustyfeet.com> Date: Sun Dec 27 16:49:37 2015 -0500
2015-12-27 rocky <rb@dustyfeet.com>
* : 3.2 bytecode
2015-12-27 rocky <rb@dustyfeet.com>
* ChangeLog, NEWS, README.rst, __pkginfo__.py: Get ready for release
@@ -20,6 +234,22 @@
DRY Python3 scanner code. Some cross version handling fixed. Some
Python 3.2 and 3.3 deparse fixes.
2015-12-27 rocky <rb@dustyfeet.com>
* README.rst, test/bytecompile-tests, uncompyle6/opcodes/Makefile,
uncompyle6/opcodes/opcode_23.py, uncompyle6/opcodes/opcode_24.py,
uncompyle6/opcodes/opcode_25.py, uncompyle6/opcodes/opcode_26.py,
uncompyle6/opcodes/opcode_27.py, uncompyle6/opcodes/opcode_32.py,
uncompyle6/opcodes/opcode_33.py, uncompyle6/opcodes/opcode_34.py,
uncompyle6/parser.py, uncompyle6/parsers/parse3.py,
uncompyle6/scanner.py, uncompyle6/scanners/scanner25.py,
uncompyle6/scanners/scanner26.py, uncompyle6/scanners/scanner27.py,
uncompyle6/scanners/scanner3.py, uncompyle6/scanners/scanner32.py,
uncompyle6/scanners/scanner33.py, uncompyle6/scanners/scanner34.py,
uncompyle6/semantics/fragments.py, uncompyle6/semantics/pysource.py:
DRY Python3 scanner code. Some cross version handling fixed. Some
Python 3.2 and 3.3 deparse fixes.
2015-12-26 rocky <rb@dustyfeet.com>
* .travis.yml, test/Makefile, uncompyle6/verify.py: Running native

View File

@@ -27,6 +27,10 @@ check:
check-2.7 check-3.3 check-3.4: pytest
$(MAKE) -C test $@
#: Tests for Python 3.5 - pytest doesn't work here
check-3.5:
$(MAKE) -C test $@
#:Tests for Python 2.6 (doesn't have pytest)
check-2.6:
$(MAKE) -C test $@

7
NEWS
View File

@@ -1,3 +1,10 @@
uncompyle6 2.1.2 2015-12-31
- Fix cross-version Marshal loading
- Handle Python 3.3 . dotted class names
- Limited 3.5 support: allows deparsing other versions
- Refactor code more, misc bug fixes
uncompyle6 2.1.1 2015-12-27
- packaging issues

View File

@@ -12,8 +12,8 @@ Introduction
*uncompyle6* translates Python byte-code back into equivalent Python
source code. It accepts byte-codes from Python version 2.5 to 3.4 or
so and has been tested on Python running versions 2.6, 2.7, 3.3 and
3.4.
so and has been tested on Python running versions 2.6, 2.7, 3.3,
3.4 and 3.5.
Why this?
---------
@@ -86,11 +86,7 @@ Known Bugs/Restrictions
-----------------------
Python 2 deparsing is probably as solid as the various versions of
uncompyle2. Python 3 deparsing is not as solid. Using Python 2 to
deparse Python 3 has severe limitations, due to byte code format
differences and the current inablity to retrieve code object fields across
different Python versions. (I envy the pycdc C++ code which doesn't have such
problems because they live totally outside of Python.)
uncompyle2. Python 3 deparsing is okay but not as solid.
See Also
--------

View File

@@ -40,7 +40,7 @@ def get_srcdir():
return os.path.realpath(filename)
ns = {}
version = '2.1.1'
version = '2.1.2'
web = 'https://github.com/rocky/python-uncompyle6/'
# tracebacks in zip files are funky and not debuggable

View File

@@ -19,28 +19,31 @@ check:
@$(PYTHON) -V && PYTHON_VERSION=`$(PYTHON) -V 2>&1 | cut -d ' ' -f 2 | cut -d'.' -f1,2`; \
$(MAKE) check-$$PYTHON_VERSION
#: Run working tests from Python 2.6
check-2.6: check-bytecode-2.7 check-bytecode-2.5
$(PYTHON) test_pythonlib.py --bytecode-2.6 --verify $(COMPILE)
#: Run working tests from Python 2.7
check-2.7: check-bytecode check-2.7-ok
#: Run working tests from Python 2.6 or 2.7
check-2.6 check-2.7: check-bytecode check-2.7-ok
#: Run working tests from Python 3.3
check-3.3: check-bytecode-3.3 check-bytecode-2.7
check-3.3: check-bytecode
$(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
check-3.4: check-bytecode-2.7 check-bytecode-3.2
$(PYTHON) test_pythonlib.py --bytecode-3.4 --ok-2.7 --verify $(COMPILE)
check-3.4: check-bytecode check-2.7-ok
#: Check deparsing only, but from a different Python version
check-disasm:
$(PYTHON) dis-compare.py
#: Check deparsing bytecode only
check-bytecode-2:
$(PYTHON) test_pythonlib.py --bytecode-2.5 --bytecode-2.6 --bytecode-2.7
#: Check deparsing bytecode only
check-bytecode:
$(PYTHON) test_pythonlib.py --bytecode-2.5 --bytecode-2.7 --bytecode-3.2
$(PYTHON) test_pythonlib.py --bytecode-2.5 --bytecode-2.6 --bytecode-2.7 \
--bytecode-3.2 --bytecode-3.3 --bytecode-3.4
#: Check deparsing Python 2.5
check-bytecode-2.5:

View File

@@ -1,77 +0,0 @@
#!/usr/bin/env python
from __future__ import print_function
"""
compile_tests -- compile test patterns for the decompyle test suite
"""
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['3.4'] = ['mine']
total_tests = len(tests['2.7'])
#tests['2.2'].sort(); print tests['2.2']
extension = '.py' + (__debug__ and 'c' or 'o')
def compile(file, target_dir):
sfile = os.path.join(src_dir, 'test_%s.py' % file)
cfile = os.path.join(target_dir, 'test_%s%s' % (file, 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 file in tests[version]:
compile(file, 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))
compile_for_version(version)
print('Done.')

View File

@@ -1,23 +0,0 @@
def kwfunc(**kwargs):
print kwargs.items()
def argsfunc(*args):
print args
def no_apply(*args, **kwargs):
print args
print kwargs.items()
argsfunc(34)
foo = argsfunc(*args)
argsfunc(*args)
argsfunc(34, *args)
kwfunc(**kwargs)
kwfunc(x=11, **kwargs)
no_apply(*args, **kwargs)
no_apply(34, *args, **kwargs)
no_apply(x=11, *args, **kwargs)
no_apply(34, x=11, *args, **kwargs)
no_apply(42, 34, x=11, *args, **kwargs)
no_apply(1,2,4,8,a=2,b=3,c=5)

View File

@@ -1,45 +0,0 @@
raise "This program can't be run"
a = 1
b = 2
a += b; print a # a = a+b = 3
a -= b; print a # a = a-b = 1
a *= b; print a # a = a*b = 2
a -= a; print a # a = a-a = 0
a += 7*3; print a # == 21
l= [1,2,3]
l[1] *= 3; print l[1]; # 6
l[1][2][3] = 7
l[1][2][3] *= 3;
l[:] += [9]; print l
l[:2] += [9]; print l
l[1:] += [9]; print l
l[1:4] += [9]; print l
l += [42,43]; print l
a.value = 1
a.value += 1;
a.b.val = 1
a.b.val += 1;
l = []
for i in range(3):
lj = []
for j in range(3):
lk = []
for k in range(3):
lk.append(0)
lj.append(lk)
l.append(lj)
i = j = k = 1
def f():
global i
i += 1
return i
l[i][j][k] = 1
i = 1
l[f()][j][k] += 1
print i, l

View File

@@ -1,34 +0,0 @@
class A:
class A1:
def __init__(self):
print 'A1.__init__'
def foo(self):
print 'A1.foo'
def __init__(self):
print 'A.__init__'
def foo(self):
print 'A.foo'
class B:
def __init__(self):
print 'B.__init__'
def bar(self):
print 'B.bar'
class C(A,B):
def foobar(self):
print 'C.foobar'
c = C()
c.foo()
c.bar()
c.foobar()

View File

@@ -1,24 +0,0 @@
raise "This program can't be run"
print 0
a = b[5]
print 1
del a
print 2
del b[5]
print 3
del testme[1]
print 4
del testme[:]
print '4a'
del testme[:42]
print '4b'
del testme[40:42]
print 5
del testme[2:1024:10]
print '5a'
del testme[40,41,42]
print 6
del testme[:42, ..., :24:, 24, 100]
print 7

View File

@@ -1,6 +0,0 @@
from __future__ import division
print ' 1 // 2 =', 1 // 2
print '1.0 // 2.0 =', 1.0 // 2.0
print ' 1 / 2 =', 1 / 2
print '1.0 / 2.0 =', 1.0 / 2.0

View File

@@ -1,6 +0,0 @@
#from __future__ import division
print ' 1 // 2 =', 1 // 2
print '1.0 // 2.0 =', 1.0 // 2.0
print ' 1 / 2 =', 1 / 2
print '1.0 / 2.0 =', 1.0 / 2.0

View File

@@ -1,34 +0,0 @@
'''
This is a doc string
'''
def Doc_Test():
"""This has to be present"""
class XXX:
def __init__(self):
"""__init__: This has to be present"""
self.a = 1
def XXX22():
"""XXX22: This has to be present"""
pass
def XXX11():
"""XXX22: This has to be present"""
pass
def XXX12():
foo = """XXX22: This has to be present"""
pass
def XXX13():
pass
def Y11():
def Y22():
def Y33():
pass
print __doc__

View File

@@ -1,107 +0,0 @@
import dis
def x11():
try:
a = 'try except'
except:
a = 2
b = '--------'
def x12():
try:
a = 'try except else(pass)'
except:
a = 2
b = '--------'
def x13():
try:
a = 'try except else(a=3)'
except:
a = 2
else:
a = 3
b = '--------'
def x21():
try:
a = 'try KeyError'
except KeyError:
a = 8
b = '--------'
def x22():
try:
a = 'try (IdxErr, KeyError) else(pass)'
except (IndexError, KeyError):
a = 8
b = '--------'
def x23():
try:
a = 'try KeyError else(a=9)'
except KeyError:
a = 8
else:
a = 9
b = '--------'
def x31():
try:
a = 'try KeyError IndexError'
except KeyError:
a = 8
except IndexError:
a = 9
b = '--------'
def x32():
try:
a = 'try KeyError IndexError else(pass)'
except KeyError:
a = 8
except IndexError:
a = 9
b = '--------'
def x33():
try:
a = 'try KeyError IndexError else(a=9)'
except KeyError:
a = 8
except IndexError:
a = 9
else:
a = 9
b = '#################'
def x41():
if (a == 1):
a = 1
elif (b == 1):
b = 1
else:
c = 1
b = '#################'
def x42():
if (a == 1):
a = 1
elif (b == 1):
b = 1
else:
c = 1
xxx = 'mmm'
if (__name__ == '__main__'):
dis.dis(xx)

View File

@@ -1,5 +0,0 @@
testcode = 'a = 12'
exec testcode
exec testcode in globals()
exec testcode in globals(), locals()

View File

@@ -1,10 +0,0 @@
def _lsbStrToInt(str):
return ord(str[0]) + \
(ord(str[1]) << 8) + \
(ord(str[2]) << 16) + \
(ord(str[3]) << 24)
def test(x):
return x
test(a == b == c == 1)

View File

@@ -1,10 +0,0 @@
import os, sys as System, time
import sys
from rfc822 import Message as Msg822
from mimetools import Message as MimeMsg, decode, choose_boundary as MimeBoundary
import test.test_StringIO as StringTest
for k, v in globals().items():
print `k`, v

View File

@@ -1,6 +0,0 @@
import sys
print >> sys.stdout, "Hello World"
print >> sys.stdout, 1,2,3
print >> sys.stdout, 1,2,3,
print >> sys.stdout

File diff suppressed because it is too large Load Diff

View File

@@ -1,58 +0,0 @@
def x0():
pass
def x1(arg1):
pass
def x2(arg1,arg2):
pass
def x3a(*args):
pass
def x3b(**kwargs):
pass
def x3c(*args, **kwargs):
pass
def x4a(foo, bar=1, bla=2, *args):
pass
def x4b(foo, bar=1, bla=2, **kwargs):
pass
def x4c(foo, bar=1, bla=2, *args, **kwargs):
pass
def func_with_tuple_args((a,b)):
print a
print b
def func_with_tuple_args2((a,b), (c,d)):
print a
print c
def func_with_tuple_args3((a,b), (c,d), *args):
print a
print c
def func_with_tuple_args4((a,b), (c,d), **kwargs):
print a
print c
def func_with_tuple_args5((a,b), (c,d), *args, **kwargs):
print a
print c
def func_with_tuple_args6((a,b), (c,d)=(2,3), *args, **kwargs):
print a
print c
def func_ret1():
return 1 < 2 < 3
def read(size=0):
if size > 0 and size <= x - cur:
return 0
return 0

View File

@@ -1,16 +0,0 @@
i = 1; j = 7
def a():
def b():
def c():
k = 34
global i
i = i+k
l = 42
c()
global j
j = j+l
b()
print i, j # should print 35, 49
a()
print i, j

View File

@@ -1,10 +0,0 @@
def f():
print x # would result in a 'NameError' or 'UnboundLocalError'
x = x+1
print x
raise "This program can't be run"
x = 1
f()
print x

View File

@@ -1,11 +0,0 @@
import sys
import os, sys, BaseHTTPServer
import test.test_MimeWriter
from rfc822 import Message
from mimetools import Message, decode, choose_boundary
from os import *
for k, v in globals().items():
print `k`, v

View File

@@ -1,13 +0,0 @@
import sys as SYS
import os as OS, sys as SYSTEM, BaseHTTPServer as HTTPServ
import test.test_MimeWriter as Mime_Writer
from rfc822 import Message as MSG
from mimetools import Message as mimeMsg, decode, \
choose_boundary as mimeBoundry
print '---' * 20
for k, v in globals().items():
print k, repr(v)

View File

@@ -1,22 +0,0 @@
import sys
#raise "This program can't be run"
i = 1
i = 42
i = -1
i = -42
i = sys.maxint
minint = -sys.maxint-1
print sys.maxint
print minint
print long(minint)-1
print
i = -2147483647 # == -maxint
print i, repr(i)
i = i-1
print i, repr(i)
i = -2147483648L # == minint == -maxint-1
print i, repr(i)
i = -2147483649L # == minint-1 == -maxint-2
print i, repr(i)

View File

@@ -1,11 +0,0 @@
for i in range(20):
print i,
print
for i in range(10):
print i,
#if i == 10: break
else:
print 'The End'

View File

@@ -1,8 +0,0 @@
palette = map(lambda a: (a,a,a), range(256))
palette = map(lambda (r,g,b): chr(r)+chr(g)+chr(b), palette)
palette = map(lambda r: r, palette)
palette = lambda (r,g,b,): r
palette = lambda (r): r
palette = lambda r: r
palette = lambda (r): r, palette

View File

@@ -1,30 +0,0 @@
XXX = range(4)
print [i for i in XXX]
print
print [i for i in (1,2,3,4,)]
print
print [i for i in [1,2,3,4,]]
print
print [(i,1) for i in XXX]
print
print [i*2 for i in range(4)]
print
print [i*j for i in range(4)
for j in range(7)]
print [i*2 for i in range(4) if i == 0 ]
print [(i,i**2) for i in range(4) if (i % 2) == 0 ]
print [i*j for i in range(4)
if i == 2
for j in range(7)
if (i+i % 2) == 0 ]
seq1 = 'abc'
seq2 = (1,2,3)
[ (x,y) for x in seq1 for y in seq2 ]
def flatten1(seq):
return [x for subseq in seq for x in subseq]
print flatten1([[0], [1,2,3], [4,5], [6,7,8,9], []])

View File

@@ -1,58 +0,0 @@
for i in range(10):
if i == 3:
continue
if i == 5:
break
print i,
else:
print 'Else'
print
for i in range(10):
if i == 3:
continue
print i,
else:
print 'Else'
i = 0
while i < 10:
i = i+1
if i == 3:
continue
if i == 5:
break
print i,
else:
print 'Else'
print
i = 0
while i < 10:
i = i+1
if i == 3:
continue
print i,
else:
print 'Else'
for x, y in [(1,2),(3,4)]:
if x in ['==', '>=', '>']:
if '0' in y:
print
for x in (1, 2, 3):
if x == 1:
print x
i = 0
while i < 10:
i+=1
for x in (1,2,3):
for y in (1,2,3):
if x == y and x == 1:
while i < 10:
print x
break

View File

@@ -1,10 +0,0 @@
# This is a seperate test pattern, since 'continue' within 'try'
# was not allowed till Python 2.1
for term in args:
try:
print
continue
print
except:
pass

View File

@@ -1,5 +0,0 @@
sum(i*i for i in range(10))
sum(x*y for x,y in zip(xvec, yvec))

View File

@@ -1,23 +0,0 @@
raise "This program can't be run"
class A:
def __init__(self, num):
self.num = num
def __repr__(self):
return str(self.num)
b = []
for i in range(10):
b.append(A(i))
for i in ('CALL_FUNCTION', 'CALL_FUNCTION_VAR',
'CALL_FUNCTION_VAR_KW', 'CALL_FUNCTION_KW'):
print i, '\t', len(i), len(i)-len('CALL_FUNCTION'),
print (len(i)-len('CALL_FUNCTION')) / 3,
print i[len('CALL_FUNCTION'):]
p2 = (0, 0, None)
if p2[2]:
print 'has value'
else:
print ' no value'

View File

@@ -1,81 +0,0 @@
a = None
if a == 1:
print '1'
elif a == 2:
print '2'
if a == 1:
print '1'
elif a == 2:
print '2'
else:
print 'other'
if a == 1:
print '1'
elif a == 2:
print '2'
elif a == 3:
print '3'
else:
print 'other'
if a == 1:
print '1'
elif a == 2:
print '2'
elif a == 3:
print '3'
if a == 1:
print '1'
else:
if a == 2:
print '2'
else:
if a == 3:
print '3'
else:
print 'other'
if a == 1:
print '1'
else:
if a == 2:
print '2'
else:
print 'more'
if a == 3:
print '3'
else:
print 'other'
if a == 1:
print '1'
else:
print 'more'
if a == 2:
print '2'
else:
if a == 3:
print '3'
else:
print 'other'
if a == 1:
print '1'
else:
print 'more'
if a == 2:
print '2'
else:
print 'more'
if a == 3:
print '3'
elif a == 4:
print '4'
elif a == 4:
print '4'
else:
print 'other'

View File

@@ -1,87 +0,0 @@
from __future__ import nested_scopes
blurb = 1
def k0():
def l0(m=1):
print
l0()
def x0():
def y0():
print
y0()
def x1():
def y1():
print 'y-blurb =', blurb
y1()
def x2():
def y2():
print
blurb = 2
y2()
def x3a():
def y3a(x):
print 'y-blurb =', blurb, flurb
print
blurb = 3
flurb = 7
y3a(1)
print 'x3a-blurb =', blurb
def x3():
def y3(x):
def z():
blurb = 25
print 'z-blurb =', blurb,
z()
print 'y-blurb =', blurb,
print
blurb = 3
y3(1)
print 'x3-blurb =', blurb
def x3b():
def y3b(x):
def z():
print 'z-blurb =', blurb,
blurb = 25
z()
print 'y-blurb =', blurb,
print
blurb = 3
y3b(1)
print 'x3-blurb =', blurb
def x4():
def y4(x):
def z():
print 'z-blurb =', blurb
z()
global blurb
blurb = 3
y4(1)
def x():
def y(x):
print 'y-blurb =', blurb
blurb = 2
y(1)
def func_with_tuple_args6((a,b), (c,d)=(2,3), *args, **kwargs):
def y(x):
print 'y-a =', a
print c
def find(self, name):
# This is taken from 'What's new in Python 2.1' by amk
L = filter(lambda x, name: x == name, self.list_attribute)
x0(); x1(); x2();
x3(); x3a(); x3b();
x4(); x()
print 'blurb =', blurb

View File

@@ -1,128 +0,0 @@
import pprint
aa = 'aa'
dict0 = {
'a': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'b': 1234,
'd': aa,
aa: aa
}
dict = {
'a': 'aaa',
'b': 1234,
'c': { 'ca': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'cb': 1234,
'cc': None
},
'd': aa,
aa: aa,
'eee': { 'ca': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'cb': 1234,
'cc': None
},
'ff': aa,
}
list1 = [ '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
aa,
'1bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'1ccccccccccccccccccccccccccccccccccccccccccc' ]
list2 = [ '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
[ '22aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
aa,
'22bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'22ccccccccccccccccccccccccccccccccccccccccccc' ],
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'ccccccccccccccccccccccccccccccccccccccccccc' ]
tuple1 = ( '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
aa,
'1bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'1ccccccccccccccccccccccccccccccccccccccccccc' )
tuple2 = ( '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
( '22aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
aa,
'22bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'22ccccccccccccccccccccccccccccccccccccccccccc' ),
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'ccccccccccccccccccccccccccccccccccccccccccc' )
def funcA():
dict = {
'a': 'aaa',
'b': 1234,
'c': { 'ca': 'aaa',
'cb': 1234,
'cc': None
},
'd': aa,
aa: aa
}
list1 = [ '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'1bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
aa,
'1ccccccccccccccccccccccccccccccccccccccccccc' ]
list2 = [ '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
[ '22aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
aa,
'22bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'22ccccccccccccccccccccccccccccccccccccccccccc' ],
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'ccccccccccccccccccccccccccccccccccccccccccc' ]
tuple1 = ( '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'1bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
aa,
'1ccccccccccccccccccccccccccccccccccccccccccc' )
tuple2 = ( '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
( '22aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
aa,
'22bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'22ccccccccccccccccccccccccccccccccccccccccccc' ),
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'ccccccccccccccccccccccccccccccccccccccccccc' )
def funcAB():
dict = {
'a': 'aaa',
'b': 1234,
'c': { 'ca': 'aaa',
'cb': 1234,
'cc': None
},
'd': aa,
aa: aa
}
list1 = [ '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'1bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'1ccccccccccccccccccccccccccccccccccccccccccc' ]
list2 = [ '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
[ '22aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'22bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'22ccccccccccccccccccccccccccccccccccccccccccc' ],
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'ccccccccccccccccccccccccccccccccccccccccccc' ]
tuple1 = ( '1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'1bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'1ccccccccccccccccccccccccccccccccccccccccccc' )
tuple2 = ( '2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
( '22aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'22bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'22ccccccccccccccccccccccccccccccccccccccccccc' ),
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
'ccccccccccccccccccccccccccccccccccccccccccc' )
pprint.pprint(dict0)
print
pprint.pprint(dict)
print
pprint = pprint.PrettyPrinter(indent=2)
pprint.pprint(dict0)
print
pprint.pprint(dict)
print
pprint.pprint(list1)
print
pprint.pprint(list2)

View File

@@ -1,9 +0,0 @@
print 1,2,3,4,5
a = b + 5
print 1,2,3,4,5
print 1,2,3,4,5
print
print
print 1,2,3,4,5
print

View File

@@ -1,13 +0,0 @@
import sys
print >>sys.stdout, 1,2,3,4,5
print >>sys.stdout, 1,2,3,4,5,
print >>sys.stdout
print >>sys.stdout, 1,2,3,4,5,
print >>sys.stdout, 1,2,3,4,5,
print >>sys.stdout
print >>sys.stdout

View File

@@ -1 +0,0 @@
print 5

View File

@@ -1,32 +0,0 @@
raise "This program can't be run"
testme[1]
testme[1] = 1
del testme[1]
testme[:42]
testme[:42] = "The Answer"
del testme[:42]
testme[2:1024:]
testme[:1024:10]
testme[::]
testme[2:1024:10]
testme[2:1024:10] = "A lot"
del testme[2:1024:10]
testme[:42, ..., :24:, 24, 100]
testme[:42, ..., :24:, 24, 100] = "Strange"
del testme[:42, ..., :24:, 24, 100]
testme[:]
testme[:] = 'Take all'
del testme[:]
testme[40:42]
testme[40:42] = 'Three'
del testme[40:42]
testme[40,41,42]
testme[40,41,42] = 'Another Three'
del testme[40,41,42]

View File

@@ -1,14 +0,0 @@
def A(a,b,(x,y,z),c):
pass
def B(a,b=42,(x,y,z)=(1,2,3),c=17):
pass
def C((x,y,z)):
pass
def D((x,)):
pass
def E((x)):
pass

View File

@@ -1,20 +0,0 @@
a = (1,)
b = (2,3)
a,b = (1,2)
a,b = ( (1,2), (3,4,5) )
x = {}
try:
x[1,2,3]
except:
pass
x[1,2,3] = 42
print x[1,2,3]
print x[(1,2,3)]
assert x[(1,2,3)] == x[1,2,3]
del x[1,2,3]
x=[1,2,3]
b=(1 for i in x if i)
b=(e for i in range(4) if i == 2)

View File

@@ -1,22 +0,0 @@
from __future__ import generators
def inorder(t):
if t:
for x in inorder(t.left):
yield x
yield t.label
for x in inorder(t.right):
yield x
def generate_ints(n):
for i in range(n):
yield i*2
for i in generate_ints(5):
print i,
print
gen = generate_ints(3)
print gen.next(),
print gen.next(),
print gen.next(),
print gen.next()

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
test/bytecode_3.2/05_if.pyc Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More