You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 16:59:52 +08:00
Compare commits
79 Commits
release-py
...
python-3.0
Author | SHA1 | Date | |
---|---|---|---|
|
011081af5a | ||
|
74c7870537 | ||
|
8d07aa0435 | ||
|
521c983b51 | ||
|
d0cd82c3d1 | ||
|
4703052817 | ||
|
2f1ab4f63e | ||
|
5be6946fbf | ||
|
7ca4363602 | ||
|
b2cf041ec3 | ||
|
5e6fad210f | ||
|
efd28710ce | ||
|
f72b2c1153 | ||
|
e4e3743de5 | ||
|
b71cd88b73 | ||
|
98a93ae6b9 | ||
|
74b39e2262 | ||
|
bb5604aaf1 | ||
|
4ac5564df3 | ||
|
e6be9cd75a | ||
|
6171165e90 | ||
|
addddf82f5 | ||
|
4181bcbc79 | ||
|
f4d21d36e5 | ||
|
54a5b45a0f | ||
|
8c15ce92f9 | ||
|
f9d32f19d4 | ||
|
9f915384ce | ||
|
2786cbcb89 | ||
|
5c391f9101 | ||
|
f4becb42e4 | ||
|
cf34014766 | ||
|
37f38e45e1 | ||
|
a2342bcbab | ||
|
c65fa2defd | ||
|
ab7980374d | ||
|
4a81ffae8f | ||
|
7fd642c70e | ||
|
454f176d6a | ||
|
bca623c53c | ||
|
964a123a1a | ||
|
6e95881fbb | ||
|
9b38760173 | ||
|
7cc8ad0b5d | ||
|
61d8dd3e1f | ||
|
27c869b69a | ||
|
7db6a272af | ||
|
bf949e83d6 | ||
|
36f455011d | ||
|
7b155c4219 | ||
|
20d0a60550 | ||
|
f721c7ff34 | ||
|
ea3873dba3 | ||
|
193c262ffb | ||
|
c24d61d6c6 | ||
|
7d017cae08 | ||
|
f0e1a7beba | ||
|
9ade8e9806 | ||
|
eb088a84c8 | ||
|
4cd10b79e2 | ||
|
f603a44cf7 | ||
|
80d58f882a | ||
|
a4818f95bc | ||
|
710167b806 | ||
|
ff192ea6c1 | ||
|
c309730748 | ||
|
e6c63e419e | ||
|
a878a74a12 | ||
|
3491fcc7d3 | ||
|
467dc6c828 | ||
|
07c0d3f1b2 | ||
|
f82caba70f | ||
|
6400f4231a | ||
|
ddcf4bb5dd | ||
|
9f756f74e6 | ||
|
20605789e1 | ||
|
fcc4535b93 | ||
|
7dacd509a8 | ||
|
e6ddaab691 |
@@ -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]
|
11
.travis.yml
11
.travis.yml
@@ -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
|
||||
|
5
Makefile
5
Makefile
@@ -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
|
||||
|
18
README.rst
18
README.rst
@@ -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
0
__init__.py
Normal 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"
|
||||
|
@@ -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
0
admin-tools/check-3.0-3.2-versions.sh
Normal file → Executable file
21
admin-tools/checkout_common.sh
Normal file
21
admin-tools/checkout_common.sh
Normal 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
|
||||
}
|
@@ -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}*
|
@@ -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
7
admin-tools/merge-for-3.6.sh
Executable 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
28
admin-tools/setup-master.sh
Normal file → Executable 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
29
admin-tools/setup-python-2.4.sh
Normal file → Executable 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
|
||||
|
@@ -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
29
admin-tools/setup-python-3.3.sh
Normal file → Executable 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
21
admin-tools/setup-python-3.6.sh
Executable 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
|
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
cd $(dirname ${BASH_SOURCE[0]})/..
|
||||
git pull
|
@@ -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')
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
@@ -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]
|
||||
|
@@ -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")
|
||||
|
2
pytest/testdata/if-2.7.right
vendored
2
pytest/testdata/if-2.7.right
vendored
@@ -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
|
||||
|
2
pytest/testdata/ifelse-2.7.right
vendored
2
pytest/testdata/ifelse-2.7.right
vendored
@@ -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
|
||||
|
@@ -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")
|
||||
|
@@ -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
|
||||
|
26
setup.py
26
setup.py
@@ -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)
|
||||
|
@@ -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()
|
@@ -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.
BIN
test/bytecode_2.4/02_slice.pyc
Normal file
BIN
test/bytecode_2.4/02_slice.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_2.4/10_for.pyc
Normal file
BIN
test/bytecode_2.4/10_for.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_2.4/10_mixed_boolean.pyc
Normal file
BIN
test/bytecode_2.4/10_mixed_boolean.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.
BIN
test/bytecode_2.6/02_slice.pyc
Normal file
BIN
test/bytecode_2.6/02_slice.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_2.6/10_for.pyc
Normal file
BIN
test/bytecode_2.6/10_for.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_2.6/10_mixed_boolean.pyc
Normal file
BIN
test/bytecode_2.6/10_mixed_boolean.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.
BIN
test/bytecode_2.7/06_nop.pyc
Normal file
BIN
test/bytecode_2.7/06_nop.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_2.7/10_del.pyc
Normal file
BIN
test/bytecode_2.7/10_del.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_2.7/16_bytestring_docstring.pyc
Normal file
BIN
test/bytecode_2.7/16_bytestring_docstring.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.1/01_ops.pyc
Normal file
BIN
test/bytecode_3.1/01_ops.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.2/01_ops.pyc
Normal file
BIN
test/bytecode_3.2/01_ops.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.6/06_nop.pyc
Normal file
BIN
test/bytecode_3.6/06_nop.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.8/16_no_bytestring_docstring.pyc
Normal file
BIN
test/bytecode_3.8/16_no_bytestring_docstring.pyc
Normal file
Binary file not shown.
@@ -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):
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
@@ -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
|
@@ -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()
|
45
test/simple_source/stmts/16_bytestring_docstring.py
Normal file
45
test/simple_source/stmts/16_bytestring_docstring.py
Normal 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()
|
||||
|
45
test/simple_source/stmts/16_no_bytestring_docstring.py
Normal file
45
test/simple_source/stmts/16_no_bytestring_docstring.py
Normal 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()
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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
Reference in New Issue
Block a user