Compare commits

..

79 Commits

Author SHA1 Message Date
rocky
011081af5a Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-12-21 02:34:10 -05:00
rocky
74c7870537 Merge branch 'python-3.6-to-3.10' into python-3.3-to-3.5 2024-12-21 02:34:01 -05:00
rocky
8d07aa0435 Merge branch 'master' into python-3.6-to-3.10 2024-12-21 02:32:06 -05:00
rocky
521c983b51 Administrivia 2024-12-21 02:31:09 -05:00
rocky
d0cd82c3d1 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-12-12 18:06:50 -05:00
rocky
4703052817 Merge branch 'python-3.6-to-3.10' into python-3.3-to-3.5 2024-12-12 18:06:33 -05:00
rocky
2f1ab4f63e Merge hell 2024-12-12 18:05:29 -05:00
rocky
5be6946fbf Merge branch 'master' into python-3.6-to-3.10 2024-12-12 18:05:09 -05:00
rocky
7ca4363602 Administrivia 2024-12-12 18:03:31 -05:00
rocky
b2cf041ec3 Remove unused import 2024-12-02 19:39:56 -05:00
R. Bernstein
5e6fad210f Merge pull request #507 from c10udlnk/master
Fix when parsing NOP
2024-12-01 15:13:25 -05:00
c10udlnk
efd28710ce Add NOP test cases
Add test cases for check NOP opcode
2024-12-01 16:22:54 +08:00
c10udlnk
f72b2c1153 Fix when parsing NOP
Fix error when parsing NOP opcode
2024-11-29 11:03:13 +08:00
rocky
e4e3743de5 Tweak when we delete LOAD_CONST RETURN_VALUE 2024-11-28 08:03:32 -05:00
rocky
b71cd88b73 Show return value when not None...
And fixup setup.py
2024-11-28 08:01:15 -05:00
rocky
98a93ae6b9 Merge branch 'master' into python-3.3-to-3.5 2024-11-28 07:30:16 -05:00
rocky
74b39e2262 Administriva 2024-11-28 07:29:37 -05:00
rocky
bb5604aaf1 Merge branch 'master' into python-3.3-to-3.5 2024-11-28 07:28:40 -05:00
rocky
4ac5564df3 Don't remove LOAD_CONST RETURN_VALUE when...
the LOAD_CONST has a non-None value, or the LOAD_CONST
has a line associated with it.
2024-11-28 07:27:13 -05:00
rocky
e6be9cd75a Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-11-26 09:46:07 -05:00
rocky
6171165e90 Merge branch 'master' into python-3.3-to-3.5 2024-11-26 09:45:42 -05:00
rocky
addddf82f5 Correct getting code node on mkfunc 2024-11-26 09:44:49 -05:00
rocky
4181bcbc79 Correct getting code node on mkfunc 2024-11-26 09:43:32 -05:00
rocky
f4d21d36e5 Add BlackHat Asia 2024 and update CircleCI link 2024-11-19 15:33:20 -05:00
rocky
54a5b45a0f Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-11-19 15:29:57 -05:00
rocky
8c15ce92f9 Merge branch 'master' into python-3.3-to-3.5 2024-11-19 15:29:40 -05:00
rocky
f9d32f19d4 Add BlackHat Asia 2024 and update CircleCI link 2024-11-19 15:27:50 -05:00
rocky
9f915384ce Bump spark_parser version allowed 2024-11-15 19:45:29 -05:00
R. Bernstein
2786cbcb89 Merge pull request #504 from rocky/TABLE_DIRECT-pollution
Don't update global tables, copy them instead.
2024-11-12 16:38:40 -05:00
rocky
5c391f9101 Update CircleCI 2024-11-12 16:35:36 -05:00
R. Bernstein
f4becb42e4 Merge pull request #505 from gdesmar/use_single_table_copy
Use a single TABLE copy
2024-11-12 16:17:59 -05:00
gdesmar
cf34014766 Use a single TABLE copy 2024-11-12 19:42:17 +00:00
rocky
37f38e45e1 Don't update global tables...
Work off of copies of them instead. Issue #503
2024-11-09 11:57:11 -05:00
rocky
a2342bcbab Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-11-09 06:39:08 -05:00
rocky
c65fa2defd Merge branch 'master' into python-3.3-to-3.5 2024-11-09 06:38:25 -05:00
rocky
ab7980374d Allow for newer spark-parser 2024-11-09 06:37:59 -05:00
rocky
4a81ffae8f Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-11-09 06:33:06 -05:00
rocky
7fd642c70e bytes/string tolerance for 3.3 2024-11-09 06:28:41 -05:00
rocky
454f176d6a Merge branch 'master' into python-3.3-to-3.5 2024-11-09 06:13:27 -05:00
rocky
bca623c53c Allow for newer spark-parser 2024-11-09 06:10:10 -05:00
rocky
964a123a1a Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-11-09 06:03:04 -05:00
rocky
6e95881fbb Merge branch 'master' into python-3.3-to-3.5 2024-11-09 06:02:50 -05:00
rocky
9b38760173 Administrivia 2024-11-09 06:02:33 -05:00
rocky
7cc8ad0b5d Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-11-09 05:41:14 -05:00
rocky
61d8dd3e1f Address package version woes 2024-11-09 05:40:46 -05:00
R. Bernstein
27c869b69a Merge pull request #502 from gdesmar/docstring_bytes
Fix for print_docstring()'s `docstring.find(quote)` Type error
2024-10-16 20:31:12 -04:00
gdesmar
7db6a272af Adding tests for bytestring docstring 2024-10-16 20:19:39 +00:00
rocky
bf949e83d6 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-10-10 17:30:42 -04:00
rocky
36f455011d Merge branch 'python-3.6-to-3.10' into python-3.3-to-3.5 2024-10-10 17:22:44 -04:00
rocky
7b155c4219 Admninistrivia 2024-10-10 17:21:29 -04:00
gdesmar
20d0a60550 Remove duplicate code of print_docstring 2024-10-10 20:24:56 +00:00
rocky
f721c7ff34 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-10-09 04:01:45 -04:00
rocky
ea3873dba3 Merge branch 'master' into python-3.3-to-3.5 2024-10-09 04:01:29 -04:00
rocky
193c262ffb Administrivia
Folloow branching of other projects in this ilk
2024-10-09 04:00:14 -04:00
rocky
c24d61d6c6 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-10-09 03:56:38 -04:00
rocky
7d017cae08 Administrivia 2024-10-08 19:23:56 -04:00
rocky
f0e1a7beba Try unpinning setuptools 2024-10-08 17:09:07 -04:00
rocky
9ade8e9806 Merge hell 2024-10-08 16:49:03 -04:00
rocky
eb088a84c8 Accept newer python-spark 2024-10-08 16:46:42 -04:00
gdesmar
4cd10b79e2 Convert docstring from bytes to str 2024-10-08 13:48:39 +00:00
rocky
f603a44cf7 Allow newer spark-parser 2024-10-07 11:09:46 -04:00
rocky
80d58f882a Track branch changes in python-spark 2024-10-04 04:46:26 -04:00
rocky
a4818f95bc Merge branch 'master' into python-3.3-to-3.5 2024-09-21 07:31:02 -04:00
rocky
710167b806 Adminsitrivia 2024-09-21 07:29:12 -04:00
rocky
ff192ea6c1 Administrivia 2024-09-21 07:25:44 -04:00
rocky
c309730748 Note version of setuptools working on Python 3.6 2024-09-20 16:23:18 -04:00
rocky
e6c63e419e Administrivia 2024-09-20 16:17:07 -04:00
rocky
a878a74a12 Fixes #501 2024-08-27 11:21:56 -04:00
rocky
3491fcc7d3 Administrivia 2024-08-18 12:49:33 -04:00
rocky
467dc6c828 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-07-22 18:33:26 -04:00
rocky
07c0d3f1b2 Merge branch 'master' into python-3.3-to-3.5 2024-07-22 18:33:15 -04:00
rocky
f82caba70f Administrivia 2024-07-22 18:31:59 -04:00
rocky
6400f4231a Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-07-22 18:03:50 -04:00
rocky
ddcf4bb5dd Merge branch 'master' into python-3.3-to-3.5 2024-07-22 18:03:44 -04:00
rocky
9f756f74e6 Administrivia 2024-07-22 18:03:17 -04:00
rocky
20605789e1 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2024-07-22 17:58:11 -04:00
rocky
fcc4535b93 Merge branch 'master' into python-3.3-to-3.5 2024-07-22 17:58:02 -04:00
rocky
7dacd509a8 Administrivia 2024-07-22 17:57:50 -04:00
rocky
e6ddaab691 Adminstiriva: bump to dev0 version 2024-07-22 05:16:10 -04:00
178 changed files with 1147 additions and 1474 deletions

View File

@@ -1,11 +0,0 @@
default_language_version:
python: python
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: debug-statements
stages: [commit]
- id: end-of-file-fixer
stages: [commit]

View File

@@ -1,7 +1,16 @@
language: python
python:
- 2.7 # this is a cheat here because travis doesn't do 2.4-2.6
# - '3.5'
# - '2.7'
# - '3.4'
- '3.6'
- '3.8'
matrix:
include:
- python: '3.7'
dist: xenial # required for Python >= 3.7 (travis-ci/travis-ci#9069)
install:
# Remove the next line when xdis 6.0.0 is released

View File

@@ -43,9 +43,8 @@ check-3.0 check-3.1 check-3.2 check-3.6:
check-3.7: pytest
$(MAKE) -C test check
#:Tests for Python 2.4-2.5 (don't have pytest)
check-2.4 check-2.5:
$(MAKE) -C test $@
check-3.8:
$(MAKE) -C test check
#:PyPy 2.6.1 PyPy 5.0.1, or PyPy 5.8.0-beta0
# Skip for now

View File

@@ -103,16 +103,16 @@ Installation
You can install from PyPI using the name ``uncompyle6``::
$ pip install uncompyle6
pip install uncompyle6
To install from source code, this project uses setup.py, so it follows the standard Python routine::
$ pip install -e . # set up to run from source tree
$ pip install -e . # set up to run from source tree
or::
$ python setup.py install # may need sudo
$ python setup.py install # may need sudo
A GNU Makefile is also provided so :code:`make install` (possibly as root or
sudo) will do the steps above.
@@ -122,7 +122,7 @@ Running Tests
::
$ make check
make check
A GNU makefile has been added to smooth over setting running the right
command, and running tests from fastest to slowest.
@@ -282,6 +282,7 @@ to spend.
See Also
--------
* https://rocky.github.io/blackhat-asia-2024-additional/all-notes-print.html : How to Read and Write a High-Level Bytecode Decompiler: ``uncompyle6`` ``decompyle3`` -- BlackHat 2024 Asia (`video <https://www.youtube.com/watch?v=NA77SFncppE>`_. A big thanks to the Organizers and Reviewers for letting me speak. This kind of thing encourages me to work on projects like this.
* https://github.com/rocky/python-decompile3 : Much smaller and more modern code, focusing on 3.7 and 3.8. Changes in that will get migrated back here.
* https://code.google.com/archive/p/unpyc3/ : supports Python 3.2 only. The above projects use a different decompiling technique than what is used here. Currently unmaintained.
* https://github.com/figment/unpyc3/ : fork of above, but supports Python 3.3 only. Includes some fixes like supporting function annotations. Currently unmaintained.
@@ -306,12 +307,15 @@ See Also
.. _uncompyle2: https://github.com/wibiti/uncompyle2
.. _unpyc37: https://github.com/andrew-tavera/unpyc37
.. _this: https://github.com/rocky/python-uncompyle6/wiki/Deparsing-technology-and-its-use-in-exact-location-reporting
.. |buildstatus| image:: https://travis-ci.org/rocky/python-uncompyle6.svg :target: https://travis-ci.org/rocky/python-uncompyle6
.. |packagestatus| image:: https://repology.org/badge/vertical-allrepos/python:uncompyle6.svg :target: https://repology.org/project/python:uncompyle6/versions
.. |buildstatus| image:: https://circleci.com/gh/rocky/python-uncompyle6.svg?style=svg
:target: https://app.circleci.com/pipelines/github/rocky/python-uncompyle6
.. |packagestatus| image:: https://repology.org/badge/vertical-allrepos/python:uncompyle6.svg
:target: https://repology.org/project/python:uncompyle6/versions
.. _PJOrion: http://www.koreanrandom.com/forum/topic/15280-pjorion-%D1%80%D0%B5%D0%B4%D0%B0%D0%BA%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5-%D0%BA%D0%BE%D0%BC%D0%BF%D0%B8%D0%BB%D1%8F%D1%86%D0%B8%D1%8F-%D0%B4%D0%B5%D0%BA%D0%BE%D0%BC%D0%BF%D0%B8%D0%BB%D1%8F%D1%86%D0%B8%D1%8F-%D0%BE%D0%B1%D1%84
.. _pydecipher: https://github.com/mitre/pydecipher
.. _Deobfuscator: https://github.com/extremecoders-re/PjOrion-Deobfuscator
.. _Py2EXE: https://en.wikipedia.org/wiki/Py2exe
.. |Supported Python Versions| image:: https://img.shields.io/pypi/pyversions/uncompyle6.svg
.. |Latest Version| image:: https://badge.fury.io/py/uncompyle6.svg :target: https://badge.fury.io/py/uncompyle6
.. |Latest Version| image:: https://badge.fury.io/py/uncompyle6.svg
:target: https://badge.fury.io/py/uncompyle6
.. |Pypi Installs| image:: https://pepy.tech/badge/uncompyle6/month

0
__init__.py Normal file
View File

View File

@@ -79,7 +79,7 @@ entry_points = {
]
}
ftp_url = None
install_requires = ["spark-parser >= 1.8.9, < 1.9.0", "xdis >= 6.1.1, < 6.2.0"]
install_requires = ["click", "spark-parser >= 1.8.9, < 1.9.2", "xdis >= 6.1.1, < 6.2.0"]
license = "GPL3"
mailing_list = "python-debugger@googlegroups.com"

View File

@@ -12,6 +12,8 @@ if ! source ./pyenv-2.4-2.7-versions ; then
exit $?
fi
if ! source ./setup-python-2.4.sh ; then
rc=$?
finish
exit $rc
fi
@@ -23,6 +25,8 @@ for version in $PYVERSIONS; do
fi
make clean && python setup.py develop
if ! make check ; then
finish
rc=$?
exit $?
fi
echo === $version ===

0
admin-tools/check-3.0-3.2-versions.sh Normal file → Executable file
View File

View File

@@ -0,0 +1,21 @@
# Common checkout routine
export PATH=$HOME/.pyenv/bin/pyenv:$PATH
bs=${BASH_SOURCE[0]}
mydir=$(dirname $bs)
fulldir=$(readlink -f $mydir)
function setup_version {
local repo=$1
version=$2
echo Running setup $version on $repo ...
(cd ../$repo && . ./admin-tools/setup-${version}.sh)
return $?
}
function checkout_finish {
branch=$1
cd $uncompyle6_owd
git checkout $branch && pyenv local $PYTHON_VERSION && git pull
rc=$?
return $rc
}

View File

@@ -1,46 +0,0 @@
git pull
Change version in uncompyle6/version.py
source uncompyle6/version.py
echo $VERSION
git commit -m"Get ready for release $VERSION" .
Update ChangeLog:
make ChangeLog
Update NEWS from ChangeLog
make check
git commit --amend .
git push
Make sure pyenv is running
# Pyenv
source admin-tools/check-newer-versions.sh
# Switch to python-2.4 and build that first...
source admin-tools/setup-python-2.4
rm ChangeLog
git merge master
Update NEWS from master branch
git commit -m"Get ready for release $VERSION" .
source admin-tools/check-older-versions.sh
source admin-tools/check-newer-versions.sh
make-dist-older.sh
git tag release-python-2.4-$VERSION
./make-dist-newer.sh
git tag release-$VERSION
twine upload dist/uncompyle6-${VERSION}*

View File

@@ -2,6 +2,6 @@
uncompyle6_merge_33_owd=$(pwd)
cd $(dirname ${BASH_SOURCE[0]})
if . ./setup-python-3.3.sh; then
git merge master
git merge python-3.6-to-3.10
fi
cd $uncompyle6_merge_33_owd

7
admin-tools/merge-for-3.6.sh Executable file
View File

@@ -0,0 +1,7 @@
#/bin/bash
uncompyle6_merge_36_owd=$(pwd)
cd $(dirname ${BASH_SOURCE[0]})
if . ./setup-python-3.6.sh; then
git merge master
fi
cd $uncompyle6_merge_36_owd

28
admin-tools/setup-master.sh Normal file → Executable file
View File

@@ -1,32 +1,20 @@
#!/bin/bash
# Check out master branch and dependent development master branches
PYTHON_VERSION=3.8.18
bs=${BASH_SOURCE[0]}
if [[ $0 == $bs ]] ; then
echo "This script should be *sourced* rather than run directly through bash"
exit 1
fi
function checkout_version {
local repo=$1
version=${2:-master}
echo Checking out $version on $repo ...
(cd ../$repo && git checkout $version && pyenv local $PYTHON_VERSION) && \
git pull
return $?
}
owd=$(pwd)
export PATH=$HOME/.pyenv/bin/pyenv:$PATH
PYTHON_VERSION=3.12
uncompyle6_owd=$(pwd)
mydir=$(dirname $bs)
fulldir=$(readlink -f $mydir)
cd $mydir
. ./checkout_common.sh
cd $fulldir/..
(cd $fulldir/.. && checkout_version python-spark && checkout_version python-xdis &&
checkout_version python-uncompyle6)
git pull
rm -v */.python-version || true
cd $owd
(cd $fulldir/.. && \
setup_version python-spark master && \
setup_version python-xdis master )
checkout_finish master

29
admin-tools/setup-python-2.4.sh Normal file → Executable file
View File

@@ -1,32 +1,23 @@
#!/bin/bash
# Check out python-2.4-to-2.7 and dependent development branches.
PYTHON_VERSION=2.4.6
bs=${BASH_SOURCE[0]}
if [[ $0 == $bs ]] ; then
echo "This script should be *sourced* rather than run directly through bash"
exit 1
fi
function checkout_version {
local repo=$1
version=${2:-python-2.4-to-2.7}
echo Checking out $version on $repo ...
(cd ../$repo && git checkout $version && pyenv local $PYTHON_VERSION) && \
git pull
return $?
}
owd=$(pwd)
export PATH=$HOME/.pyenv/bin/pyenv:$PATH
PYTHON_VERSION=2.4
uncompyle6_owd=$(pwd)
mydir=$(dirname $bs)
fulldir=$(readlink -f $mydir)
(cd $fulldir/.. && checkout_version python-spark && checkout_version python-xdis python-2.4-to-2.7 &&
checkout_version python-uncompyle6)
cd $mydir
. ./checkout_common.sh
git pull
rm -v */.python-version || true
cd $owd
(cd $fulldir/.. && \
setup_version python-spark python-2.4 && \
setup_version python-xdis python-2.4)
checkout_finish python-2.4-to-2.7

View File

@@ -1,35 +1,20 @@
#!/bin/bash
# Check out python-3.0-to-3.2 and dependent development branches.
PYTHON_VERSION=3.0.1
bs=${BASH_SOURCE[0]}
if [[ $0 == $bs ]] ; then
echo "This script should be *sourced* rather than run directly through bash"
exit 1
fi
# FIXME put some of the below in a common routine
function checkout_version {
local repo=$1
version=${2:-python-3.0-to-3.2}
echo Checking out $version on $repo ...
(cd ../$repo && git checkout $version && pyenv local $PYTHON_VERSION) && \
git pull
return $?
}
owd=$(pwd)
trap finish EXIT
export PATH=$HOME/.pyenv/bin/pyenv:$PATH
PYTHON_VERSION=3.0
uncompyle6_owd=$(pwd)
mydir=$(dirname $bs)
fulldir=$(readlink -f $mydir)
cd $fulldir/..
(cd $fulldir/.. && checkout_version python-spark master && checkout_version python-xdis &&
checkout_version python-uncompyle6)
cd $mydir
. ./checkout_common.sh
(cd $fulldir/.. && \
setup_version python-spark python-3.0 && \
setup_version python-xdis python-3.0)
git pull
rm -v */.python-version || true
cd $owd
checkout_finish python-3.0-to-3.2

29
admin-tools/setup-python-3.3.sh Normal file → Executable file
View File

@@ -1,34 +1,21 @@
#!/bin/bash
# Check out python-3.3-to-3.5 and dependent development branches.
PYTHON_VERSION=3.3.7
bs=${BASH_SOURCE[0]}
if [[ $0 == $bs ]] ; then
echo "This script should be *sourced* rather than run directly through bash"
exit 1
fi
# FIXME put some of the below in a common routine
function checkout_version {
local repo=$1
version=${2:-python-3.3-to-3.5}
echo Checking out $version on $repo ...
(cd ../$repo && git checkout $version && pyenv local $PYTHON_VERSION) && \
git pull
return $?
}
owd=$(pwd)
export PATH=$HOME/.pyenv/bin/pyenv:$PATH
PYTHON_VERSION=3.3
uncompyle6_owd=$(pwd)
mydir=$(dirname $bs)
cd $mydir
fulldir=$(readlink -f $mydir)
. ./checkout_common.sh
cd $fulldir/..
(cd $fulldir/.. && checkout_version python-spark master && checkout_version python-xdis &&
checkout_version python-uncompyle6)
rm -v */.python-version || true
(cd $fulldir/.. && \
setup_version python-spark python-3.3 && \
setup_version python-xdis python-3.3 )
git pull
rm -v */.python-version || true
cd $owd
checkout_finish python-3.3-to-3.5

21
admin-tools/setup-python-3.6.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# Check out python-3.6-to-3.10 and dependent development branches.
bs=${BASH_SOURCE[0]}
if [[ $0 == $bs ]] ; then
echo "This script should be *sourced* rather than run directly through bash"
exit 1
fi
PYTHON_VERSION=3.6
uncompyle6_owd=$(pwd)
mydir=$(dirname $bs)
cd $mydir
fulldir=$(readlink -f $mydir)
. ./checkout_common.sh
cd $fulldir/..
(cd $fulldir/.. && \
setup_version python-spark python-3.6 && \
setup_version python-xdis python-3.6 )
checkout_finish python-3.6-to-3.10

View File

@@ -1,3 +0,0 @@
#!/bin/bash
cd $(dirname ${BASH_SOURCE[0]})/..
git pull

View File

@@ -29,7 +29,7 @@ def list_comp():
[y for y in range(3)]
def get_parsed_for_fn(fn):
code = fn.func_code
code = fn.__code__
return deparse(code, version=PYTHON_VERSION_TRIPLE)
def check_expect(expect, parsed, fn_name):
@@ -316,4 +316,3 @@ for i in range(2): ...
.
""".split("\n")
parsed = get_parsed_for_fn(for_range_stmt)
check_expect(expect, parsed, 'range_stmt')

View File

@@ -20,7 +20,7 @@ def bug_loop(disassemble, tb=None):
disassemble(tb)
def test_if_in_for():
code = bug.func_code
code = bug.__code__
scan = get_scanner(PYTHON_VERSION_TRIPLE)
if (2, 7) <= PYTHON_VERSION_TRIPLE < (3, 1) and not IS_PYPY:
scan.build_instructions(code)

View File

@@ -1,9 +1,7 @@
import re
from xdis.version_info import IS_PYPY, PYTHON_VERSION_TRIPLE
from uncompyle6.parser import get_python_parser, python_parser
from uncompyle6.scanner import get_scanner
from xdis.version_info import PYTHON_VERSION_TRIPLE, IS_PYPY
def test_grammar():
@@ -30,7 +28,7 @@ def test_grammar():
expect_lhs.add("get_iter")
if PYTHON_VERSION_TRIPLE >= (3, 8):
if PYTHON_VERSION_TRIPLE >= (3, 8) or PYTHON_VERSION_TRIPLE < (3, 0):
expect_lhs.add("stmts_opt")
else:
expect_lhs.add("async_with_as_stmt")
@@ -47,34 +45,28 @@ def test_grammar():
expect_lhs.add("kvlist")
expect_lhs.add("kv3")
unused_rhs.add("dict")
else:
if PYTHON_VERSION_TRIPLE < (3, 7) and PYTHON_VERSION_TRIPLE[:2] not in (
(2, 7),
(2, 6),
):
if PYTHON_VERSION_TRIPLE < (3, 7) and PYTHON_VERSION_TRIPLE[:2] != (2, 7):
# NOTE: this may disappear
expect_lhs.add("except_handler_else")
expect_lhs.add("kwarg")
if PYTHON_VERSION_TRIPLE >= (3, 0):
expect_lhs.add("load_genexpr")
expect_lhs.add("load_genexpr")
unused_rhs = unused_rhs.union(
set(
"""
except_pop_except generator_exp
""".split()
)
unused_rhs = unused_rhs.union(
set(
"""
except_pop_except generator_exp
""".split()
)
if PYTHON_VERSION_TRIPLE < (3, 7):
expect_lhs.add("annotate_arg")
expect_lhs.add("annotate_tuple")
unused_rhs.add("mkfunc_annotate")
unused_rhs.add("dict_comp")
unused_rhs.add("classdefdeco1")
unused_rhs.add("tryelsestmtl")
)
if PYTHON_VERSION_TRIPLE < (3, 7):
expect_lhs.add("annotate_arg")
expect_lhs.add("annotate_tuple")
unused_rhs.add("mkfunc_annotate")
unused_rhs.add("dict_comp")
unused_rhs.add("classdefdeco1")
unused_rhs.add("tryelsestmtl")
if PYTHON_VERSION_TRIPLE >= (3, 5):
expect_right_recursive.add(
(("l_stmts", ("lastl_stmt", "come_froms", "l_stmts")))
@@ -106,9 +98,7 @@ def test_grammar():
)
reduced_dup_rhs = dict((k, dup_rhs[k]) for k in dup_rhs if k not in expect_dup_rhs)
if reduced_dup_rhs:
print(
"\nPossible duplicate RHS that might be folded, into one of the LHS symbols"
)
print("\nPossible duplicate RHS that might be folded, into one of the LHS symbols")
for k in reduced_dup_rhs:
print(k, reduced_dup_rhs[k])
# assert not reduced_dup_rhs, reduced_dup_rhs

View File

@@ -5,7 +5,9 @@ from uncompyle6.semantics.consts import (
# RETURN_NONE, PASS, RETURN_LOCALS
)
from StringIO import StringIO
from io import StringIO
def iteritems(d):
return d.items()
from uncompyle6.semantics.pysource import (SourceWalker, deparse_code2str)
@@ -22,7 +24,7 @@ def test_template_engine():
# FIXME: and so on...
from uncompyle6.semantics.consts import (
TABLE_R, TABLE_DIRECT,
TABLE_DIRECT, TABLE_R,
)
from uncompyle6.semantics.fragments import (
@@ -36,7 +38,7 @@ def test_tables():
(TABLE_DIRECT, 'TABLE_DIRECT', False),
(TABLE_R, 'TABLE_R', False),
(TABLE_DIRECT_FRAGMENT, 'TABLE_DIRECT_FRAGMENT', True)):
for k, entry in t.iteritems():
for k, entry in iteritems(t):
if k in skip_for_now:
continue
fmt = entry[0]

View File

@@ -1,20 +1,22 @@
import pytest
from uncompyle6 import code_deparse
from xdis.version_info import PYTHON_VERSION_TRIPLE
pytest.mark.skip(PYTHON_VERSION_TRIPLE < (2, 7), reason="need Python < 2.7")
if PYTHON_VERSION_TRIPLE == (2, 7):
def test_single_mode():
single_expressions = (
'i = 1',
'i and (j or k)',
'i += 1',
'i = j % 4',
'i = {}',
'i = []',
'for i in range(10):\n i\n',
'for i in range(10):\n for j in range(10):\n i + j\n',
'try:\n i\nexcept Exception:\n j\nelse:\n k\n'
)
def test_single_mode():
single_expressions = (
"i = 1",
"i and (j or k)",
"i += 1",
"i = j % 4",
"i = {}",
"i = []",
"for i in range(10):\n i\n",
"for i in range(10):\n for j in range(10):\n i + j\n",
# 'try:\n i\nexcept Exception:\n j\nelse:\n k\n'
)
for expr in single_expressions:
code = compile(expr + "\n", "<string>", "single")

View File

@@ -9,4 +9,4 @@
12 JUMP_FORWARD 0 'to 15'
15_0 COME_FROM 12 '12'
15 LOAD_CONST None
18 RETURN_VALUE
18 RETURN_VALUE

View File

@@ -12,4 +12,4 @@
18 STORE_NAME 2 'd'
21_0 COME_FROM 12 '12'
21 LOAD_CONST None
24 RETURN_VALUE
24 RETURN_VALUE

View File

@@ -17,12 +17,6 @@ from xdis import Bytecode, get_opcode
opc = get_opcode(PYTHON_VERSION_TRIPLE, IS_PYPY)
Bytecode = functools.partial(Bytecode, opc=opc)
if PYTHON_VERSION_TRIPLE < (2, 5):
from cStringIO import StringIO
else:
from StringIO import StringIO
import six
def _dis_to_text(co):
@@ -128,7 +122,7 @@ def validate_uncompyle(text, mode="exec"):
original_text = text
deparsed = code_deparse(
original_code, out=StringIO(), version=PYTHON_VERSION_TRIPLE, compile_mode=mode
original_code, out=six.StringIO(), version=PYTHON_VERSION_TRIPLE, compile_mode=mode
)
uncompyled_text = deparsed.text
uncompyled_code = compile(uncompyled_text, "<string>", "exec")

View File

@@ -1,7 +1,9 @@
# Pick up stuff from setup.py
hypothesis==2.0.0
pytest
-e .
Click~=7.0
xdis >= 6.1.0, < 6.2.0
configobj~=5.0.6
setuptools~=59.6.0
setuptools

View File

@@ -1,28 +1,30 @@
#!/usr/bin/env python
"""Setup script for the 'uncompyle6' distribution."""
import setuptools
import sys
import setuptools
SYS_VERSION = sys.version_info[0:2]
if not ((2, 4) <= SYS_VERSION <= (2, 7)):
mess = "Python Release 2.4 .. 2.7 are supported in this code branch."
if ((3, 6) <= SYS_VERSION < (3, 9)):
mess += ("\nFor your Python, version %s, use the master code/branch." %
sys.version[0:3])
elif (3, 3) <= SYS_VERSION <= (3, 6):
if not ((3, 0) <= SYS_VERSION < (3, 3)):
mess = "Python Release 3.0 .. 3.2 are supported in this code branch."
if (2, 4) <= SYS_VERSION <= (2, 7):
mess += (
"\nFor your Python, version %s, use the python-3.3-3.5 code/branch."
"\nFor your Python, version %s, use the python-2.4 code/branch."
% sys.version[0:3]
)
elif (3, 0) >= SYS_VERSION < (3, 3):
if SYS_VERSION >= (3, 6):
mess += (
"\nFor your Python, version %s, use the python-3.0-to-3.2 code/branch."
"\nFor your Python, version %s, use the master code/branch."
% sys.version[0:3]
)
if (3, 3) >= SYS_VERSION < (3, 6):
mess += (
"\nFor your Python, version %s, use the python-3.3-to-3.6 code/branch."
% sys.version[0:3]
)
elif SYS_VERSION < (2, 4):
mess += (
"\nThis package is not supported for Python before Python 2.4 version %s." % sys.version[0:3]
"\nThis package is not supported for Python version %s." % sys.version[0:3]
)
print(mess)
raise Exception(mess)

View File

@@ -1,85 +0,0 @@
import re
import unittest
from xdis.version_info import IS_PYPY, PYTHON_VERSION_TRIPLE
from uncompyle6.parser import get_python_parser, python_parser
class TestGrammar(unittest.TestCase):
def test_grammar(self):
def check_tokens(tokens, opcode_set):
remain_tokens = set(tokens) - opcode_set
remain_tokens = set([re.sub("_\d+$", "", t) for t in remain_tokens])
remain_tokens = set([re.sub("_CONT$", "", t) for t in remain_tokens])
remain_tokens = set(remain_tokens) - opcode_set
self.assertEqual(
remain_tokens,
set([]),
"Remaining tokens %s\n====\n%s" % (remain_tokens, p.dump_grammar()),
)
p = get_python_parser(PYTHON_VERSION_TRIPLE, is_pypy=IS_PYPY)
(lhs, rhs, tokens, right_recursive, dup_rhs) = p.check_sets()
expect_lhs = set(["pos_arg", "get_iter", "attribute"])
unused_rhs = set(["list", "call", "mkfunc", "unpack", "lambda_body"])
expect_right_recursive = frozenset(
[("designList", ("store", "DUP_TOP", "designList"))]
)
expect_lhs.add("kwarg")
if PYTHON_VERSION_TRIPLE[:2] <= (3, 6):
unused_rhs.add("call")
if PYTHON_VERSION_TRIPLE[:2] == (2, 7):
expect_lhs.add("kv3")
expect_lhs.add("kvlist")
unused_rhs.add("dict")
self.assertEqual(expect_lhs, set(lhs))
self.assertEqual(unused_rhs, set(rhs))
self.assertEqual(expect_right_recursive, right_recursive)
expect_dup_rhs = frozenset(
[
("COME_FROM",),
("CONTINUE",),
("JUMP_ABSOLUTE",),
("LOAD_CONST",),
("JUMP_BACK",),
("JUMP_FORWARD",),
]
)
reduced_dup_rhs = {}
for k in dup_rhs:
if k not in expect_dup_rhs:
reduced_dup_rhs[k] = dup_rhs[k]
pass
pass
for k in reduced_dup_rhs:
print(k, reduced_dup_rhs[k])
# assert not reduced_dup_rhs, reduced_dup_rhs
# FIXME: Something got borked here
def no_test_dup_rule(self):
import inspect
python_parser(
PYTHON_VERSION_TRIPLE,
inspect.currentframe().f_code,
is_pypy=IS_PYPY,
parser_debug={
"dups": True,
"transition": False,
"reduce": False,
"rules": False,
"errorstack": None,
"context": True,
},
)
if __name__ == "__main__":
unittest.main()

View File

@@ -30,46 +30,55 @@ check:
$(MAKE) check-$(PYTHON_VERSION)
#: Run working tests from Python 2.6 or 2.7
check-2.4 check-2.5 check-2.6 check-2.7: check-bytecode-2 check-bytecode-3 check-bytecode-1 check-native-short
check-2.6 check-2.7: check-bytecode-2 check-bytecode-3 check-bytecode-1 check-native-short
#: Run working tests from Python 3.0
check-3.0: check-bytecode
$(PYTHON) test_pythonlib.py --bytecode-3.0-run
$(PYTHON) test_pythonlib.py --bytecode-3.0-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.0 --syntax-verify $(COMPILE)
#: Run working tests from Python 3.1
check-3.1: check-bytecode
$(PYTHON) test_pythonlib.py --bytecode-3.1-run
$(PYTHON) test_pythonlib.py --bytecode-3.1-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.1 --syntax-verify $(COMPILE)
#: Run working tests from Python 3.2
check-3.2: check-bytecode
$(PYTHON) test_pythonlib.py --bytecode-3.2-run
$(PYTHON) test_pythonlib.py --bytecode-3.2-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.2 --syntax-verify $(COMPILE)
#: Run working tests from Python 3.3
check-3.3: check-bytecode
$(PYTHON) test_pythonlib.py --bytecode-3.3-run
$(PYTHON) test_pythonlib.py --bytecode-3.3-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.3 --syntax-verify $(COMPILE)
#: Run working tests from Python 3.4
check-3.4: check-bytecode check-3.4-ok check-2.7-ok
$(PYTHON) test_pythonlib.py --bytecode-3.4-run
$(PYTHON) test_pythonlib.py --bytecode-3.4-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.4 --syntax-verify $(COMPILE)
#: Run working tests from Python 3.5
check-3.5: check-bytecode
$(PYTHON) test_pythonlib.py --bytecode-3.5-run
$(PYTHON) test_pythonlib.py --bytecode-3.5-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.5 --syntax-verify $(COMPILE)
#: Run working tests from Python 3.6
check-3.6: check-bytecode
$(PYTHON) test_pythonlib.py --bytecode-3.6-run
$(PYTHON) test_pythonlib.py --bytecode-3.6-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.6 --syntax-verify $(COMPILE)
#: Run working tests from Python 3.7
check-3.7: check-bytecode
$(PYTHON) test_pythonlib.py --bytecode-3.7-run
$(PYTHON) test_pythonlib.py --bytecode-3.7-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.7 --syntax-verify $(COMPILE)
# #: Run working tests from Python 3.8
# check-3.8: check-bytecode
# $(PYTHON) test_pythonlib.py --bytecode-3.8-run --verify-run
# $(PYTHON) test_pythonlib.py --bytecode-3.8 --syntax-verify $(COMPILE)
check-pypy37: check-bytecode
$(PYTHON) test_pythonlib.py --bytecode-pypy37
$(PYTHON) test_pythonlib.py --bytecode-pypy37 --verify-run
#: Run working tests from Python 3.8
check-3.8: check-bytecode
$(PYTHON) test_pythonlib.py --bytecode-3.8-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.8 --syntax-verify $(COMPILE)
check-3.9: check-bytecode
@echo "Note that we do not support decompiling Python 3.9 bytecode - no 3.9 tests run"
@@ -265,58 +274,54 @@ grammar-coverage-3.7:
#: Check deparsing Python 3.0
check-bytecode-3.0:
$(PYTHON) test_pythonlib.py --bytecode-3.0-run
$(PYTHON) test_pythonlib.py --bytecode-3.0
$(PYTHON) test_pythonlib.py --bytecode-3.0-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.0 --syntax-verify
#: Check deparsing Python 3.1
check-bytecode-3.1:
$(PYTHON) test_pythonlib.py --bytecode-3.1-run
$(PYTHON) test_pythonlib.py --bytecode-3.1
$(PYTHON) test_pythonlib.py --bytecode-3.1-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.1 --syntax-verify
#: Check deparsing Python 3.2
check-bytecode-3.2:
$(PYTHON) test_pythonlib.py --bytecode-3.2-run
$(PYTHON) test_pythonlib.py --bytecode-3.2
$(PYTHON) test_pythonlib.py --bytecode-3.2-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.2 --syntax-verify
#: Check deparsing Python 3.3
check-bytecode-3.3:
$(PYTHON) test_pythonlib.py --bytecode-3.3-run
$(PYTHON) test_pythonlib.py --bytecode-3.3
$(PYTHON) test_pythonlib.py --bytecode-3.3-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.3 --syntax-verify
#: Check deparsing Python 3.4
check-bytecode-3.4:
$(PYTHON) test_pythonlib.py --bytecode-3.4-run
$(PYTHON) test_pythonlib.py --bytecode-3.4
$(PYTHON) test_pythonlib.py --bytecode-3.4-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.4 --syntax-verify
#: Check deparsing Python 3.5
check-bytecode-3.5:
$(PYTHON) test_pythonlib.py --bytecode-3.5-run
$(PYTHON) test_pythonlib.py --bytecode-3.5
$(PYTHON) test_pythonlib.py --bytecode-3.5-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.5 --syntax-verify
#: Check deparsing Python 3.6
check-bytecode-3.6:
$(PYTHON) test_pythonlib.py --bytecode-3.6-run
$(PYTHON) test_pythonlib.py --bytecode-3.6
$(PYTHON) test_pythonlib.py --bytecode-3.6-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.6 --syntax-verify
#: Check deparsing Python 3.7
check-bytecode-3.7:
$(PYTHON) test_pythonlib.py --bytecode-3.7-run
$(PYTHON) test_pythonlib.py --bytecode-3.7
$(PYTHON) test_pythonlib.py --bytecode-3.7-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.7 --syntax-verify
#: Check deparsing Python 3.8
check-bytecode-3.8:
$(PYTHON) test_pythonlib.py --bytecode-3.8-run
$(PYTHON) test_pythonlib.py --bytecode-3.8
$(PYTHON) test_pythonlib.py --bytecode-3.8-run --verify-run
$(PYTHON) test_pythonlib.py --bytecode-3.8 --syntax-verify
#: short tests for bytecodes only for this version of Python
check-native-short:
$(PYTHON) test_pythonlib.py --bytecode-$(PYTHON_VERSION) --syntax-verify $(COMPILE)
$(PYTHON) test_pythonlib.py --bytecode-$(PYTHON_VERSION)-run --verify-run $(COMPILE)
#: Run longer Python 2.6's lib files known to be okay
check-2.4-ok:
$(PYTHON) test_pythonlib.py --ok-2.4 --verify $(COMPILE)
#: Run longer Python 2.6's lib files known to be okay
check-2.6-ok:
$(PYTHON) test_pythonlib.py --ok-2.6 --syntax-verify $(COMPILE)

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.

View File

@@ -1,16 +1,17 @@
#!/usr/bin/env python
# Mode: -*- python -*-
#
# Copyright (c) 2015, 2017, 2022 by Rocky Bernstein <rb@dustyfeet.com>
# Copyright (c) 2015 by Rocky Bernstein <rb@dustyfeet.com>
#
from __future__ import print_function
import dis, os.path
from xdis import PYTHON_VERSION_TRIPL< PYTHON_VERSION_STR
if PYTHON_VERSION_TRIPLE < (2, 5):
from cStringIO import StringIO
else:
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
program = os.path.basename(__file__)
@@ -22,7 +23,7 @@ Usage: %s [OPTIONS]... FILE
usage_short = "Usage: %s [OPTIONS]... FILE" % program
import uncompyle6
from uncompyle6 check_python_version
from uncompyle6 import PYTHON_VERSION_STR, check_python_version
from uncompyle6.disas import disco
def inst_fmt(inst):

View File

@@ -34,9 +34,10 @@ else
fi
MAIN="test_pyenvlib.py"
USER=${USER:-rocky}
EMAIL=${EMAIL:-rb@dustyfeet.com}
WHAT="uncompyle6 2.4 ${MAIN}"
WHAT="uncompyle6 ${MAIN}"
MAX_TESTS=${MAX_TESTS:-800}
export BATCH=1
@@ -44,7 +45,7 @@ typeset -i RUN_STARTTIME=$(date +%s)
# PYVERSIONS="3.5.6"
MAILBODY=/tmp/${MAIN}-mailbody-$$.txt
# for VERSION in 2.4.6 2.5.9 ; do
# for VERSION in 3.3.7 ; do
for VERSION in $PYVERSIONS ; do
typeset -i rc=0
LOGFILE=/tmp/${MAIN}-$VERSION-$$.log

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python
from uncompyle6 import uncompyle
from __future__ import print_function
from uncompyle6.main import decompile
from xdis import sysinfo2float
import sys, inspect

View File

@@ -1,17 +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,7 +0,0 @@
# From 2.4 test_array.py
# In Python 2.4 and earlier "yield" is not valid and instead
# we must use "yield None". Bug was not adding "None"
def yield_bug():
yield None
return

View File

@@ -1,19 +0,0 @@
# From 2.4 test_sax.py
# Bug was distinguishing try from try/else
def verify_empty_attrs():
gvqk = 3
try:
gvk = 1/0
except ZeroDivisionError:
gvk = 1
try:
gvqk = 0
except KeyError:
gvqk = 1
# If try/else was used above the return will be 4
return gvk + gvqk
assert 1 == verify_empty_attrs()

View File

@@ -0,0 +1,45 @@
"""Module docstring"""
class A:
b"""Got \xe7\xfe Bytes?"""
assert __doc__ == b"""Got \xe7\xfe Bytes?"""
def class_func(self):
b"""Got \xe7\xfe Bytes?"""
assert __doc__ == """Module docstring"""
class B:
"""Got no Bytes?"""
assert __doc__ == """Got no Bytes?"""
def class_func(self):
"""Got no Bytes?"""
assert __doc__ == """Module docstring"""
def single_func():
"""single docstring?"""
assert __doc__ == """Module docstring"""
def single_byte_func():
b"""Got \xe7\xfe Bytes?"""
assert __doc__ == """Module docstring"""
assert __doc__ == """Module docstring"""
assert single_func.__doc__ == """single docstring?"""
single_func()
assert single_byte_func.__doc__ == b"""Got \xe7\xfe Bytes?"""
single_byte_func()
assert A.__doc__ == b"""Got \xe7\xfe Bytes?"""
assert A.class_func.__doc__ == b"""Got \xe7\xfe Bytes?"""
a = A()
assert a.class_func.__doc__ == b"""Got \xe7\xfe Bytes?"""
a.class_func()
assert B.__doc__ == """Got no Bytes?"""
assert B.class_func.__doc__ == """Got no Bytes?"""
b = B()
assert b.class_func.__doc__ == """Got no Bytes?"""
b.class_func()

View File

@@ -0,0 +1,45 @@
"""Module docstring"""
class A:
b"""Got \xe7\xfe Bytes?"""
assert __doc__ == """Module docstring"""
def class_func(self):
b"""Got \xe7\xfe Bytes?"""
assert __doc__ == """Module docstring"""
class B:
"""Got no Bytes?"""
assert __doc__ == """Got no Bytes?"""
def class_func(self):
"""Got no Bytes?"""
assert __doc__ == """Module docstring"""
def single_func():
"""single docstring?"""
assert __doc__ == """Module docstring"""
def single_byte_func():
b"""Got \xe7\xfe Bytes?"""
assert __doc__ == """Module docstring"""
assert __doc__ == """Module docstring"""
assert single_func.__doc__ == """single docstring?"""
single_func()
assert single_byte_func.__doc__ is None
single_byte_func()
assert A.__doc__ is None
assert A.class_func.__doc__ is None
a = A()
assert a.class_func.__doc__ is None
a.class_func()
assert B.__doc__ == """Got no Bytes?"""
assert B.class_func.__doc__ == """Got no Bytes?"""
b = B()
assert b.class_func.__doc__ == """Got no Bytes?"""
b.class_func()

View File

@@ -5,7 +5,6 @@ SKIP_TESTS=(
[test_ftplib.py]=1 # FIXME: Works on c90ff51
[test_slice.py]=1 # FIXME: Works on c90ff51
[test_sort.py]=1 # FIXME: Works on c90ff51
[test_strftime.py]=1 # FIXME: Works on c90ff51
[test_timeit.py]=1 # FIXME: Works on c90ff51
[test_os.py]=1 # parse error FIXME: Works on c90ff51

View File

@@ -1,151 +0,0 @@
#!/bin/bash
echo "This needs work"
exit 0
me=${BASH_SOURCE[0]}
# Note: for 2.6 sometimes we need to set PYTHON=pytest
PYTHON=${PYTHON:-python}
typeset -i BATCH=${BATCH:-0}
if (( ! BATCH )) ; then
isatty=$(/usr/bin/tty 2>/dev/null)
if [[ -n $isatty ]] && [[ "$isatty" != 'not a tty' ]] ; then
BATCH=0
fi
fi
function displaytime {
local T=$1
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
(( D > 0 )) && printf '%d days ' $D
(( H > 0 )) && printf '%d hours ' $H
(( M > 0 )) && printf '%d minutes ' $M
(( D > 0 || H > 0 || M > 0 )) && printf 'and '
printf '%d seconds\n' $S
}
FULLVERSION=2.7.18
IS_PYPY=0
MINOR=${FULLVERSION##?.?.}
STOP_ONERROR=${STOP_ONERROR:-1}
typeset -i timeout=15
function timeout_cmd {
(
$@ &
child=$!
trap -- "" SIGTERM
(
sleep "$timeout"
if ps -p $child >/dev/null ; then
echo ""
echo >&1 "**Killing ${2}; takes more than $timeout seconds to run"
kill -TERM ${child}
fi
) &
wait "$child"
)
}
. ./2.7-exclude.sh
# Test directory setup
srcdir=$(dirname $me)
cd $srcdir
fulldir=$(pwd)
# DECOMPILER=uncompyle2
DECOMPILER=${DECOMPILER:-"$fulldir/../../bin/uncompyle6"}
OPTS=${OPTS:-""}
TESTDIR=/tmp/test2.7
if [[ -e $TESTDIR ]] ; then
rm -fr $TESTDIR
fi
mkdir $TESTDIR || exit $?
(cd /usr/local/lib/python2.7/site-packages && cp */test*.pyc $TESTDIR)
(cd /usr/local/lib/python2.7/site-packages && cp */*/test*.pyc $TESTDIR)
cd $TESTDIR
export PATH=/usr/local/bin/python:${PATH}
DONT_SKIP_TESTS=${DONT_SKIP_TESTS:-0}
# Run tests
typeset -i i=0
typeset -i allerrs=0
if [[ -n $1 ]] ; then
files=$@
typeset -a files_ary=( $(echo $@) )
if (( ${#files_ary[@]} == 1 || DONT_SKIP_TESTS == 1 )) ; then
SKIP_TESTS=()
fi
elif [[ "$CIRCLECI" == "true" ]] ; then
files=$(echo test_*.pyc)
else
files=$(echo test_*.py)
fi
typeset -i ALL_FILES_STARTTIME=$(date +%s)
typeset -i skipped=0
NOT_INVERTED_TESTS=${NOT_INVERTED_TESTS:-1}
for file in $files; do
# If the fails *before* decompiling, skip it!
typeset -i STARTTIME=$(date +%s)
if [ ! -r $file ]; then
echo "Skipping test $file -- not readable. Does it exist?"
continue
elif ! $PYTHON $file >/dev/null 2>&1 ; then
echo "Skipping test $file -- it fails on its own"
continue
fi
typeset -i ENDTIME=$(date +%s)
typeset -i time_diff
(( time_diff = ENDTIME - STARTTIME))
if (( time_diff > timeout )) ; then
echo "Skipping test $file -- test takes too long to run: $time_diff seconds"
continue
fi
((i++))
# (( i > 40 )) && break
short_name=$(basename $file .py)
if ((IS_PYPY)); then
decompiled_file=$short_name-${MAJOR}.${MINOR}.pyc
else
decompiled_file=$short_name-${PYVERSION}.pyc
fi
$fulldir/compile-file.py $file && \
mv $file{,.orig} && \
echo ========== $(date +%X) Decompiling $file ===========
$DECOMPILER $OPTS $decompiled_file > $file 2>/dev/null
rc=$?
if (( rc == 0 )) ; then
echo ========== $(date +%X) Running $file ===========
timeout_cmd $PYTHON $file
rc=$?
else
echo ======= Skipping $file due to compile/decompile errors ========
fi
(( rc != 0 && allerrs++ ))
if (( STOP_ONERROR && rc )) ; then
echo "** Ran $i tests before failure. Skipped $skipped test for known failures. **"
exit $allerrs
fi
done
typeset -i ALL_FILES_ENDTIME=$(date +%s)
(( time_diff = ALL_FILES_ENDTIME - ALL_FILES_STARTTIME))
printf "Ran $i unit-test files, $allerrs errors; Elapsed time: "
displaytime $time_diff
echo "Skipped $skipped test for known failures."
exit $allerrs

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