You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Compare commits
180 Commits
release-py
...
3.7.4
Author | SHA1 | Date | |
---|---|---|---|
|
28855767fb | ||
|
8eb4d6a576 | ||
|
b4db22d525 | ||
|
8879708da7 | ||
|
67c45467c3 | ||
|
33bff4dc47 | ||
|
71c17c4e53 | ||
|
a5cfd81805 | ||
|
64f19bf188 | ||
|
ff08f8a977 | ||
|
3ae4fda292 | ||
|
6cb6e45789 | ||
|
024a81c053 | ||
|
a0f93f7ad9 | ||
|
d3d67441d1 | ||
|
a215ee2f00 | ||
|
f62512dd65 | ||
|
0f80c38530 | ||
|
bd07de5172 | ||
|
e36945e2d9 | ||
|
25df0bdb76 | ||
|
29ceb3fe05 | ||
|
fd7e04fa5d | ||
|
5079164db2 | ||
|
815ae2c5cd | ||
|
54932d36fa | ||
|
fa1d7e4af4 | ||
|
bfd4b4cd68 | ||
|
430fd2fa85 | ||
|
ef59b9c304 | ||
|
084e183577 | ||
|
7c14cf2d66 | ||
|
1d3fdbb4cd | ||
|
b21e8b8b57 | ||
|
4007b8b702 | ||
|
598b58796d | ||
|
f7bad891a4 | ||
|
357f28dd89 | ||
|
5cc572147a | ||
|
11be90758f | ||
|
e3720515ae | ||
|
7dec354a47 | ||
|
2a8daca25d | ||
|
7799819cad | ||
|
c6c50b5dfb | ||
|
d357898bbf | ||
|
c4e7ddf90a | ||
|
02f502c40a | ||
|
de4fbb08f2 | ||
|
e14675c2dc | ||
|
3449be024b | ||
|
8b50b15f0a | ||
|
e2e925679d | ||
|
7deeee8502 | ||
|
acdd025162 | ||
|
9acb3cf068 | ||
|
40a653cd3b | ||
|
3ac3979535 | ||
|
7eba933cfa | ||
|
ad5d3333da | ||
|
e046323b31 | ||
|
e80c13170a | ||
|
889417caeb | ||
|
5a83c7c643 | ||
|
31db2f3e04 | ||
|
7fa851765d | ||
|
d7c3b8454b | ||
|
3fb8d90407 | ||
|
ff43565981 | ||
|
4365022f40 | ||
|
d343384db7 | ||
|
87a891ca54 | ||
|
b94c649776 | ||
|
f34375ba99 | ||
|
81b704f597 | ||
|
5233a0716b | ||
|
a810ed1280 | ||
|
ab54caae34 | ||
|
d3cf87e2d9 | ||
|
c5228dbdc4 | ||
|
a72163f6f9 | ||
|
3e1300eb23 | ||
|
a4eaeea5b2 | ||
|
1141dfefc2 | ||
|
302a5d53d4 | ||
|
698a3073d0 | ||
|
e6adf822cc | ||
|
8c5acef792 | ||
|
7578253f7d | ||
|
9e193fd7cb | ||
|
ab6b12be56 | ||
|
5bd97aa756 | ||
|
5237d704fa | ||
|
a01285e4a9 | ||
|
1d7e8f1617 | ||
|
ced33a8f0b | ||
|
dc7f1ed0cc | ||
|
fc00d394ec | ||
|
e2baccb4e5 | ||
|
c99cf7a653 | ||
|
999eee4b5f | ||
|
9ca94717e0 | ||
|
b77efec36c | ||
|
17d07eaf00 | ||
|
538c2e7efd | ||
|
ebc22e32e6 | ||
|
4796fb9e70 | ||
|
ea81ac7202 | ||
|
2fd61b1016 | ||
|
ebd0eaa609 | ||
|
badfe5456f | ||
|
f117feb585 | ||
|
204b07c996 | ||
|
869e48877c | ||
|
7ed40d5f6e | ||
|
5c6365d8a1 | ||
|
42d3c4db61 | ||
|
f3b102600e | ||
|
f6a13302fb | ||
|
e8e7d2086d | ||
|
1367709399 | ||
|
3dcc20f6d7 | ||
|
5c83de830f | ||
|
451f0b55bb | ||
|
a5704cd462 | ||
|
52fbf1d6a7 | ||
|
0a3f951682 | ||
|
7b4059820f | ||
|
9caac7fc84 | ||
|
ceb26d29fd | ||
|
9ec1c420e7 | ||
|
a616e1e1c7 | ||
|
b839abcfe7 | ||
|
e2d349f781 | ||
|
af8add9df4 | ||
|
3afc5a599a | ||
|
663bc06bb9 | ||
|
63d6054640 | ||
|
1c8805ecc9 | ||
|
5fde4f2e05 | ||
|
b030a5ac2b | ||
|
01ea45a3f5 | ||
|
2b2e7d3242 | ||
|
2448f24764 | ||
|
299fd93125 | ||
|
d9b2d66843 | ||
|
d070a28635 | ||
|
092874f8b5 | ||
|
5a6a41a608 | ||
|
201635de7b | ||
|
81899a82c3 | ||
|
76085a3040 | ||
|
35127452f5 | ||
|
970cad7cc7 | ||
|
69064f4c23 | ||
|
28ef04d141 | ||
|
fd36c77d2d | ||
|
534afb3f6e | ||
|
874d196e5c | ||
|
dca2224520 | ||
|
e90455dcb8 | ||
|
6dd97568f6 | ||
|
aa6849a570 | ||
|
749493631c | ||
|
7b3c91d23a | ||
|
bd0fdd0002 | ||
|
c62daaf0b7 | ||
|
66d8526d7f | ||
|
66db4cc862 | ||
|
bf288b1871 | ||
|
d2f6223e14 | ||
|
9d5a4c822e | ||
|
05e0a5661a | ||
|
76287162da | ||
|
d64fa6ba50 | ||
|
b76f7f905c | ||
|
c31384ef81 | ||
|
727dabff6a | ||
|
946d74ad36 | ||
|
ebad4e2a9a |
@@ -36,10 +36,11 @@ jobs:
|
||||
# fallback to using the latest cache if no exact match is found
|
||||
- v2-dependencies-
|
||||
|
||||
# This is based on your 1.0 configuration file or project settings
|
||||
- run: pip install --user --upgrade setuptools
|
||||
- run: pip install --user -e .
|
||||
- run: pip install --user -r requirements-dev.txt
|
||||
- run:
|
||||
command: | # Use pip to install dependengcies
|
||||
pip install --user --upgrade setuptools
|
||||
pip install --user -e .
|
||||
pip install --user -r requirements-dev.txt
|
||||
|
||||
# Save dependency cache
|
||||
- save_cache:
|
||||
|
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [rocky]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
36
.github/ISSUE_TEMPLATE/bug-report.md
vendored
36
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@@ -4,28 +4,40 @@ about: Tell us about uncompyle6 bugs
|
||||
|
||||
---
|
||||
|
||||
<!-- __Note:__ Have you read https://github.com/rocky/python-uncompyle6/blob/master/HOW-TO-REPORT-A-BUG.md ?
|
||||
<!-- __Note:__ Bugs are not for asking questions about a problem you
|
||||
are trying to solve that involve the use of uncompyle6 along the way,
|
||||
although I may be more tolerent of this if you sponsor the project.
|
||||
|
||||
Also, the unless you are a sponsor of the project, it may take a
|
||||
while, maybe a week or so, before the bug report is noticed, let alone
|
||||
acted upon.
|
||||
|
||||
To set expectations, some legitimate bugs can take years
|
||||
to fix, but they eventually do get fixed. Funding the project was
|
||||
added to address the problem that there are lots of people seeking
|
||||
help and reporting bugs, but few people who are willing or capable of
|
||||
providing help or fixing bugs.
|
||||
|
||||
Finally, have you read https://github.com/rocky/python-uncompyle6/blob/master/HOW-TO-REPORT-A-BUG.md
|
||||
?
|
||||
|
||||
|
||||
Please remove any of the optional sections if they are not applicable.
|
||||
|
||||
Prerequisites
|
||||
Prerequisites/Caveats
|
||||
|
||||
* Make sure the bytecode you have can be disassembled with a
|
||||
disassembler and produces valid results.
|
||||
* Don't put bytecode and corresponding source code on any service that
|
||||
requires registration to download.
|
||||
* When you open a bug report there is no privacy. If the legitimacy of
|
||||
the activity is deemed suspicous, I may flag it as suspicious,
|
||||
* When you open a bug report there is no privacy. If you need privacy, then
|
||||
contact me by email and explain who you are and the need for privacy.
|
||||
But be mindful that you may be asked to sponsor the project for the
|
||||
personal and private help that you are requesting.
|
||||
* If the legitimacy of the activity is deemed suspicous, I may flag it as suspicious,
|
||||
making the issue even more easy to detect.
|
||||
|
||||
Bug reports that violate a prerequisite may be discarded.
|
||||
|
||||
Note that there are way more bug-fix requestors than there are bug
|
||||
fixers. If you want you need more immediate, confidential or urgent
|
||||
assistance
|
||||
|
||||
http://www.crazy-compilers.com/decompyle/ offers a byte-code
|
||||
decompiler service for versions of Python up to 2.6.
|
||||
Bug reports that violate the above may be discarded.
|
||||
|
||||
-->
|
||||
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,6 +10,7 @@
|
||||
/.pytest_cache
|
||||
/.python-version
|
||||
/.tox
|
||||
.mypy_cache
|
||||
/.venv*
|
||||
/README
|
||||
/__pkginfo__.pyc
|
||||
|
@@ -1,9 +1,9 @@
|
||||
language: python
|
||||
|
||||
python:
|
||||
- '3.5'
|
||||
- '2.7'
|
||||
- '3.4'
|
||||
# - '3.5'
|
||||
# - '2.7'
|
||||
# - '3.4'
|
||||
- '3.6'
|
||||
- '3.8'
|
||||
|
||||
|
@@ -30,31 +30,9 @@ files that I know of that will cause problems. See, for example, the
|
||||
list in
|
||||
[`test/stdlib/runtests.sh`](https://github.com/rocky/python-uncompyle6/blob/master/test/stdlib/runtests.sh).
|
||||
|
||||
But I understand: you would the bugs _you_ encounter addressed before
|
||||
all the other known bugs.
|
||||
There are far more bug reporters than there are bug fixers.
|
||||
|
||||
From my standpoint, the good thing about the bugs listed in
|
||||
`runtests.sh` is that each test case is small and isolated to a single
|
||||
kind of problem. And I'll tend to fix easier, more isolated cases than
|
||||
generic "something's wrong" kinds of bugs where I'd have to do a bit
|
||||
of work to figure out what's up, if not use some sort of mind reading,
|
||||
make some guesses, and perform some experiments to see if the guesses
|
||||
are correct. I can't read minds, nor am I into guessing games; I'd
|
||||
rather devote the effort spent instead towards fixing bugs that are
|
||||
precisely defined.
|
||||
|
||||
And it often turns out that by just fixing the well-defined and
|
||||
prescribed cases, the ill-defined amorphous cases as well will get
|
||||
handled as well.
|
||||
|
||||
In sum, you may need to do some work to have the bug you have found
|
||||
handled before the hundreds of other bugs, and other things I could be
|
||||
doing.
|
||||
|
||||
No one is getting paid to work to work on this project, let alone the
|
||||
bugs you may have an interest in. If you require decompiling bytecode
|
||||
immediately, consider using a decompilation service, listed further
|
||||
down in this document.
|
||||
Unless you are a sponsor of this project, it may take a while, maybe a week or so, before the bug report is noticed, let alone acted upon. Things eventually get fixed, but it may take years.
|
||||
|
||||
# Is it really a bug?
|
||||
|
||||
@@ -176,11 +154,7 @@ provide the input command and the output from that, please give:
|
||||
|
||||
## But I don't *have* the source code!
|
||||
|
||||
Sure, I get it. No problem. There is Python assembly code on parse
|
||||
errors, so simply by hand decompile that. To get a full disassembly,
|
||||
use `pydisasm` from the [xdis](https://pypi.python.org/pypi/xdis)
|
||||
package. Opcodes are described in the documentation for
|
||||
the [dis](https://docs.python.org/3.6/library/dis.html) module.
|
||||
There is Python assembly code on parse errors, so simply by hand decompile that. To get a full disassembly, use `pydisasm` from the [xdis](https://pypi.python.org/pypi/xdis) package. Opcodes are described in the documentation for the[dis](https://docs.python.org/3.6/library/dis.html) module.
|
||||
|
||||
### But I don't *have* the source code and am incapable of figuring how to do a hand disassembly!
|
||||
|
||||
@@ -189,7 +163,7 @@ disassemble Python bytecode. And as Richard Feynman once said, "What
|
||||
one fool can learn, so can another."
|
||||
|
||||
If this is too difficult, or too time consuming, or not of interest to
|
||||
you, then perhaps what require is a decompilation service. [Crazy
|
||||
you, then you might consider sponsoring the project. [Crazy
|
||||
Compilers](http://www.crazy-compilers.com/decompyle/) offers a
|
||||
byte-code decompiler service for versions of Python up to 2.6. (If
|
||||
there are others around let me know and I'll list them here.)
|
||||
@@ -217,10 +191,7 @@ likely the problem will be fixed and fixed sooner.
|
||||
# Karma
|
||||
|
||||
I realize that following the instructions given herein puts a bit of
|
||||
burden on the bug reporter. In my opinion, this is justified as
|
||||
attempts to balance somewhat the burden and effort needed to fix the
|
||||
bug and the attempts to balance number of would-be bug reporters with
|
||||
the number of bug fixers. Better bug reporters are more likely to move
|
||||
burden on the bug reporter. This is justified as attempts to balance somewhat the burden and effort needed to fix the bug and the attempts to balance number of would-be bug reporters with the number of bug fixers. Better bug reporters are more likely to move
|
||||
in the category of bug fixers.
|
||||
|
||||
The barrier to reporting a big is pretty small: all you really need is
|
||||
@@ -228,22 +199,14 @@ a github account, and the ability to type something after clicking
|
||||
some buttons. So the reality is that many people just don't bother to
|
||||
read these instructions, let alone follow it to any simulacrum.
|
||||
|
||||
And the reality is also that bugs sometimes get fixed even though
|
||||
these instructions are not followed.
|
||||
That said, bugs sometimes get fixed even though these instructions are not followed.
|
||||
|
||||
So one factors I may take into consideration is the bug reporter's karma.
|
||||
I may take into consideration is the bug reporter's karma.
|
||||
|
||||
* Have you demonstrably contributed to open source? I may look at your github profile to see what contributions you have made, how popular those contributions are, or how popular you are.
|
||||
* How appreciative are you? Have you starred this project that you are seeking help from? Have you starred _any_ github project? And the above two kind of feed into ...
|
||||
* Attitude. Some people feel that they are doing me and the world a great favor by just pointing out that there is a problem whose solution would greatly benefit them. (This might account partially those that have this attitude often don't read or follow instructions such as those given here.)
|
||||
|
||||
* Have you demonstrably contributed to open source? I may look at your
|
||||
github profile to see what contributions you have made, how popular
|
||||
those contributions are, or how popular you are.
|
||||
* How appreciative are you? Have you starred this project that you are
|
||||
seeking help from? Have you starred _any_ github project? And the above
|
||||
two kind of feed into ...
|
||||
* Attitude. Some people feel that they are doing me and the world a
|
||||
great favor by just pointing out that there is a problem whose solution
|
||||
would greatly benefit them. Perhaps this is why they feel that
|
||||
instructions are not to be followed by them, nor any need for
|
||||
showing evidence gratitude when help is offered them.
|
||||
|
||||
# Confidentiality of Bug Reports
|
||||
|
||||
@@ -255,6 +218,8 @@ remains would not be an issue.
|
||||
However feel free to remove any comments, and modify variable names
|
||||
or constants in the source code.
|
||||
|
||||
If there is some legitimate reason to keep confidentiality, you can contact me by email to explain the extenuating circumstances. However I tend to discard without reading anonymous email.
|
||||
|
||||
# Ethics
|
||||
|
||||
I do not condone using this program for unethical or illegal purposes.
|
||||
|
79
NEWS.md
79
NEWS.md
@@ -1,3 +1,82 @@
|
||||
3.7.4: 2020-8-05
|
||||
================
|
||||
|
||||
* Fragment parsing was borked. This means deparsing in trepan2/trepan3k was broken
|
||||
* 3.7+: narrow precedence for call tatement
|
||||
* del_stmt -> delete to better match Python AST
|
||||
* 3.8+ Add another `forelsestmt` (found only in a loop)
|
||||
* 3.8+ Add precedence on walrus operator
|
||||
* More files blackened
|
||||
* bump min xdis version
|
||||
|
||||
3.7.3: 2020-7-25
|
||||
================
|
||||
|
||||
Mostly small miscellaneous bug fixes
|
||||
|
||||
* `__doc__ = DocDescr()` from `test_descr.py` was getting confused as a docstring.
|
||||
* detect 2.7 exchandler range better
|
||||
* Add for .. else reduction checks on 2.6 and before
|
||||
* Add reduce check for 2.7 augmented assign
|
||||
* Add VERSION in a pydoc-friendly way
|
||||
|
||||
|
||||
3.7.2: 2020-6-27
|
||||
================
|
||||
|
||||
* Use newer xdis
|
||||
* Docstrings (again) which were broken again on earlier Python
|
||||
* Fix 2.6 and 2.7 decompilation bug in handling "list if" comprehensions
|
||||
|
||||
|
||||
|
||||
3.7.1: 2020-6-12 Fleetwood66
|
||||
====================================================
|
||||
|
||||
Released to pick up new xdis version which has fixes to read bytestings better on 3.x
|
||||
|
||||
* Handle 3.7+ "else" branch removal adAs seen in `_cmp()` of `python3.8/distutils/version.py` with optimization `-O2`
|
||||
* 3.6+ "with" and "with .. as" grammar improvements
|
||||
* ast-check for "for" loop was missing some grammar rules
|
||||
|
||||
3.7.0: 2020-5-19 Primidi 1st Prairial - Alfalfa - HF
|
||||
====================================================
|
||||
|
||||
The main impetus for this release is to pull in the recent changes from xdis.
|
||||
We simplify imports using xdis 4.6.0.
|
||||
|
||||
There were some bugfixes to Python 3.4-3.8. See the ChangeLog for details
|
||||
|
||||
|
||||
3.6.7: 2020-4-27 xdis again
|
||||
===========================
|
||||
|
||||
More upheaval in xdis which we need to track here.
|
||||
|
||||
3.6.6: 2020-4-20 Love in the time of Cholera
|
||||
============================================
|
||||
|
||||
The main reason for this release is an incompatablity bump in xdis which handles
|
||||
3.7 SipHash better.
|
||||
|
||||
* Go over "yield" as an expression precidence
|
||||
* Some small alignment with code in decompyle3 for "or" and "and" was done
|
||||
|
||||
|
||||
3.6.5: 2020-4-1 April Fool
|
||||
==========================
|
||||
|
||||
Back port some of the changes in decompile3 here which mostly helps 3.7 and 3.8 decompilation, although this may also help 3.6ish versions too.
|
||||
|
||||
- Handle nested `async for in for...` and better async comprehension detection via `xdis`. Still more work is needed.
|
||||
- include token number in listings when `-g` and there is a parser error
|
||||
- remove unneeded `Makefile`s now that remake 4.3+1.5dbg is a thing that has `-c`
|
||||
- Bug in finding annotations in functions with docstrings
|
||||
- Fix bug found by 2.4 sre_parse.py testing
|
||||
- Fix `transform` module's `ifelseif` bugs
|
||||
- Fix bug in 3.0 name module detection
|
||||
- Fix docstring detection
|
||||
|
||||
3.6.4: 2020-2-9 Plateau
|
||||
=======================
|
||||
|
||||
|
72
README.rst
72
README.rst
@@ -54,7 +54,7 @@ only; another patched that and handled only 3.3. You get the
|
||||
idea. This code pulls all of these forks together and *moves
|
||||
forward*. There is some serious refactoring and cleanup in this code
|
||||
base over those old forks. Even more experimental refactoring is going
|
||||
on in decompile3_.
|
||||
on in decompyle3_.
|
||||
|
||||
This demonstrably does the best in decompiling Python across all
|
||||
Python versions. And even when there is another project that only
|
||||
@@ -68,10 +68,9 @@ are syntactically correct by running the Python interpreter for that
|
||||
bytecode version. Finally, in cases where the program has a test for
|
||||
itself, we can run the check on the decompiled code.
|
||||
|
||||
We are serious about testing, and use automated processes to find
|
||||
bugs. In the issue trackers for other decompilers, you will find a
|
||||
number of bugs we've found along the way. Very few to none of them are
|
||||
fixed in the other decompilers.
|
||||
We use an automated processes to find bugs. In the issue trackers for
|
||||
other decompilers, you will find a number of bugs we've found along
|
||||
the way. Very few to none of them are fixed in the other decompilers.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
@@ -172,15 +171,11 @@ All of the Python decompilers that I have looked at have problems
|
||||
decompiling Python's control flow. In some cases we can detect an
|
||||
erroneous decompilation and report that.
|
||||
|
||||
Python support is strongest in Python 2 for 2.7 and drops off as you
|
||||
get further away from that. Support is also probably pretty good for
|
||||
python 2.3-2.4 since a lot of the goodness of early the version of the
|
||||
decompiler from that era has been preserved (and Python compilation in
|
||||
that era was minimal)
|
||||
Python support is pretty good for Python 2
|
||||
|
||||
There is some work to do on the lower end Python versions which is
|
||||
more difficult for us to handle since we don't have a Python
|
||||
interpreter for versions 1.6, and 2.0.
|
||||
On the lower end of Python versions, decompilation seems pretty good although
|
||||
we don't have any automated testing in place for Python's distributed tests.
|
||||
Also, we don't have a Python interpreter for versions 1.6, and 2.0.
|
||||
|
||||
In the Python 3 series, Python support is is strongest around 3.4 or
|
||||
3.3 and drops off as you move further away from those versions. Python
|
||||
@@ -195,7 +190,7 @@ added. So in sum handling control flow by ad hoc means as is currently
|
||||
done is worse.
|
||||
|
||||
Between Python 3.5, 3.6, 3.7 there have been major changes to the
|
||||
:code:`MAKE_FUNCTION` and :code:`CALL_FUNCTION` instructions. Python
|
||||
:code:`MAKE_FUNCTION` and :code:`CALL_FUNCTION` instructions.
|
||||
|
||||
Python 3.8 removes :code:`SETUP_LOOP`, :code:`SETUP_EXCEPT`,
|
||||
:code:`BREAK_LOOP`, and :code:`CONTINUE_LOOP`, instructions which may
|
||||
@@ -211,26 +206,52 @@ however that the magic of a released version is usually the same as
|
||||
the *last* candidate version prior to release.
|
||||
|
||||
There are also customized Python interpreters, notably Dropbox,
|
||||
which use their own magic and encrypt bytcode. With the exception of
|
||||
which use their own magic and encrypt bytecode. With the exception of
|
||||
the Dropbox's old Python 2.5 interpreter this kind of thing is not
|
||||
handled.
|
||||
|
||||
We also don't handle PJOrion_ obfuscated code. For that try: PJOrion
|
||||
Deobfuscator_ to unscramble the bytecode to get valid bytecode before
|
||||
trying this tool. This program can't decompile Microsoft Windows EXE
|
||||
files created by Py2EXE_, although we can probably decompile the code
|
||||
after you extract the bytecode properly. For situations like this, you
|
||||
might want to consider a decompilation service like `Crazy Compilers
|
||||
<http://www.crazy-compilers.com/decompyle/>`_. Handling
|
||||
pathologically long lists of expressions or statements is slow.
|
||||
We also don't handle PJOrion_ or otherwise obfuscated code. For
|
||||
PJOrion try: PJOrion Deobfuscator_ to unscramble the bytecode to get
|
||||
valid bytecode before trying this tool. This program can't decompile
|
||||
Microsoft Windows EXE files created by Py2EXE_, although we can
|
||||
probably decompile the code after you extract the bytecode
|
||||
properly. Handling pathologically long lists of expressions or
|
||||
statements is slow. We don't handle Cython_ or MicroPython which don't
|
||||
use bytecode.
|
||||
|
||||
There are numerous bugs in decompilation. And that's true for every
|
||||
other CPython decompiler I have encountered, even the ones that
|
||||
claimed to be "perfect" on some particular version like 2.4.
|
||||
|
||||
There is lots to do, so please dig in and help.
|
||||
As Python progresses decompilation also gets harder because the
|
||||
compilation is more sophisticated and the language itself is more
|
||||
sophisticated. I suspect that attempts there will be fewer ad-hoc
|
||||
attempts like unpyc37_ (which is based on a 3.3 decompiler) simply
|
||||
because it is harder to do so. The good news, at least from my
|
||||
standpoint, is that I think I understand what's needed to address the
|
||||
problems in a more robust way. But right now until such time as
|
||||
project is better funded, I do not intend to make any serious effort
|
||||
to support Python versions 3.8 or 3.9, including bugs that might come
|
||||
in. I imagine at some point I may be interested in it.
|
||||
|
||||
You can easily find bugs by running the tests against the standard
|
||||
test suite that Python uses to check itself. At any given time, there are
|
||||
dozens of known problems that are pretty well isolated and that could
|
||||
be solved if one were to put in the time to do so. The problem is that
|
||||
there aren't that many people who have been working on bug fixing.
|
||||
|
||||
Some of the bugs in 3.7 and 3.8 are simply a matter of back-porting
|
||||
the fixes in decmopyle3.
|
||||
|
||||
You may run across a bug, that you want to report. Please do so. But
|
||||
be aware that it might not get my attention for a while. If you
|
||||
sponsor or support the project in some way, I'll prioritize your
|
||||
issues above the queue of other things I might be doing instead.
|
||||
|
||||
See Also
|
||||
--------
|
||||
|
||||
* https://github.com/rocky/python-decompile3 : Much smaller and more modern code, focusing on 3.7+. Changes in that will get migrated back ehre.
|
||||
* https://github.com/rocky/python-decompile3 : Much smaller and more modern code, focusing on 3.7+. 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.
|
||||
* https://github.com/wibiti/uncompyle2 : supports Python 2.7 only, but does that fairly well. There are situations where :code:`uncompyle6` results are incorrect while :code:`uncompyle2` results are not, but more often uncompyle6 is correct when uncompyle2 is not. Because :code:`uncompyle6` adheres to accuracy over idiomatic Python, :code:`uncompyle2` can produce more natural-looking code when it is correct. Currently :code:`uncompyle2` is lightly maintained. See its issue `tracker <https://github.com/wibiti/uncompyle2/issues>`_ for more details
|
||||
@@ -242,6 +263,7 @@ See Also
|
||||
* https://github.com/zrax/pycdc : The README for this C++ code says it aims to support all versions of Python. It is best for Python versions around 2.7 and 3.3 when the code was initially developed. Accuracy for current versions of Python3 and early versions of Python is lacking. Without major effort, it is unlikely it can be made to support current Python 3. See its `issue tracker <https://github.com/zrax/pycdc/issues>`_ for details. Currently lightly maintained.
|
||||
|
||||
|
||||
.. _Cython: https://en.wikipedia.org/wiki/Cython
|
||||
.. _trepan: https://pypi.python.org/pypi/trepan2g
|
||||
.. _compiler: https://pypi.python.org/pypi/spark_parser
|
||||
.. _HISTORY: https://github.com/rocky/python-uncompyle6/blob/master/HISTORY.md
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2018 Rocky Bernstein <rocky@gnu.org>
|
||||
# Copyright (C) 2018, 2020 Rocky Bernstein <rocky@gnu.org>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -21,66 +21,83 @@
|
||||
# less elegant than having it here with reduced code, albeit there
|
||||
# still is some room for improvement.
|
||||
|
||||
# Python-version | package | last-version |
|
||||
# -----------------------------------------
|
||||
# 2.5 | pip | 1.1 |
|
||||
# 2.6 | pip | 1.5.6 |
|
||||
# 2.7 | pip | 19.2.3 |
|
||||
# 2.7 | pip | 1.2.1 |
|
||||
# 3.1 | pip | 1.5.6 |
|
||||
# 3.2 | pip | 7.1.2 |
|
||||
# 3.3 | pip | 10.0.1 |
|
||||
# 3.4 | pip | 19.1.1 |
|
||||
|
||||
# Things that change more often go here.
|
||||
copyright = """
|
||||
Copyright (C) 2015-2019 Rocky Bernstein <rb@dustyfeet.com>.
|
||||
copyright = """
|
||||
Copyright (C) 2015-2020 Rocky Bernstein <rb@dustyfeet.com>.
|
||||
"""
|
||||
|
||||
classifiers = ["Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 2.4",
|
||||
"Programming Language :: Python :: 2.5",
|
||||
"Programming Language :: Python :: 2.6",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
"Programming Language :: Python :: 3.0",
|
||||
"Programming Language :: Python :: 3.1",
|
||||
"Programming Language :: Python :: 3.2",
|
||||
"Programming Language :: Python :: 3.3",
|
||||
"Programming Language :: Python :: 3.4",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Topic :: Software Development :: Debuggers",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
]
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 2.4",
|
||||
"Programming Language :: Python :: 2.5",
|
||||
"Programming Language :: Python :: 2.6",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
"Programming Language :: Python :: 3.0",
|
||||
"Programming Language :: Python :: 3.1",
|
||||
"Programming Language :: Python :: 3.2",
|
||||
"Programming Language :: Python :: 3.3",
|
||||
"Programming Language :: Python :: 3.4",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Topic :: Software Development :: Debuggers",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
]
|
||||
|
||||
# The rest in alphabetic order
|
||||
author = "Rocky Bernstein, Hartmut Goebel, John Aycock, and others"
|
||||
author_email = "rb@dustyfeet.com"
|
||||
entry_points = {
|
||||
author = "Rocky Bernstein, Hartmut Goebel, John Aycock, and others"
|
||||
author_email = "rb@dustyfeet.com"
|
||||
entry_points = {
|
||||
"console_scripts": [
|
||||
"uncompyle6=uncompyle6.bin.uncompile:main_bin",
|
||||
"pydisassemble=uncompyle6.bin.pydisassemble:main",
|
||||
]}
|
||||
ftp_url = None
|
||||
install_requires = ["spark-parser >= 1.8.9, < 1.9.0",
|
||||
"xdis >= 4.2.2, < 4.3.0"]
|
||||
]
|
||||
}
|
||||
ftp_url = None
|
||||
install_requires = ["spark-parser >= 1.8.9, < 1.9.0", "xdis >= 5.0.4, <5.1.0"]
|
||||
|
||||
license = "GPL3"
|
||||
mailing_list = "python-debugger@googlegroups.com"
|
||||
modname = "uncompyle6"
|
||||
py_modules = None
|
||||
short_desc = "Python cross-version byte-code decompiler"
|
||||
web = "https://github.com/rocky/python-uncompyle6/"
|
||||
license = "GPL3"
|
||||
mailing_list = "python-debugger@googlegroups.com"
|
||||
modname = "uncompyle6"
|
||||
py_modules = None
|
||||
short_desc = "Python cross-version byte-code decompiler"
|
||||
web = "https://github.com/rocky/python-uncompyle6/"
|
||||
|
||||
# tracebacks in zip files are funky and not debuggable
|
||||
zip_safe = True
|
||||
|
||||
|
||||
import os.path
|
||||
|
||||
|
||||
def get_srcdir():
|
||||
filename = os.path.normcase(os.path.dirname(os.path.abspath(__file__)))
|
||||
return os.path.realpath(filename)
|
||||
|
||||
|
||||
srcdir = get_srcdir()
|
||||
|
||||
|
||||
def read(*rnames):
|
||||
return open(os.path.join(srcdir, *rnames)).read()
|
||||
|
||||
|
||||
# Get info from files; set: long_description and VERSION
|
||||
long_description = ( read("README.rst") + "\n" )
|
||||
long_description = read("README.rst") + "\n"
|
||||
exec(read("uncompyle6/version.py"))
|
||||
|
@@ -2,17 +2,17 @@
|
||||
**Table of Contents**
|
||||
|
||||
- [Get latest sources:](#get-latest-sources)
|
||||
- [Change version in uncompyle6/version.py](#change-version-in-uncompyle6versionpy)
|
||||
- [Change version in uncompyle6/version.py:](#change-version-in-uncompyle6versionpy)
|
||||
- [Update ChangeLog:](#update-changelog)
|
||||
- [Update NEWS from ChangeLog:](#update-news-from-changelog)
|
||||
- [Update NEWS.md from ChangeLog:](#update-newsmd-from-changelog)
|
||||
- [Make sure pyenv is running and check newer versions](#make-sure-pyenv-is-running-and-check-newer-versions)
|
||||
- [Switch to python-2.4, sync that up and build that first since it creates a tarball which we don't want.](#switch-to-python-24-sync-that-up-and-build-that-first-since-it-creates-a-tarball-which-we-dont-want)
|
||||
- [Update NEWS from master branch](#update-news-from-master-branch)
|
||||
- [Check against all versions](#check-against-all-versions)
|
||||
- [Check against older versions](#check-against-older-versions)
|
||||
- [Make packages and tag](#make-packages-and-tag)
|
||||
- [Upload single package and look at Rst Formating](#upload-single-package-and-look-at-rst-formating)
|
||||
- [Upload rest of versions](#upload-rest-of-versions)
|
||||
- [Push tags:](#push-tags)
|
||||
- [Check package on github](#check-package-on-github)
|
||||
- [Release on Github](#release-on-github)
|
||||
- [Get onto PyPI](#get-onto-pypi)
|
||||
- [Update tags:](#update-tags)
|
||||
|
||||
<!-- markdown-toc end -->
|
||||
# Get latest sources:
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
# Make sure pyenv is running and check newer versions
|
||||
|
||||
$ pyenv local && source admin-tools/check-newer-versions.sh
|
||||
$ admin-tools/check-newer-versions.sh
|
||||
|
||||
# Switch to python-2.4, sync that up and build that first since it creates a tarball which we don't want.
|
||||
|
||||
@@ -50,37 +50,51 @@
|
||||
|
||||
# Check against older versions
|
||||
|
||||
$ source admin-tools/check-older-versions.sh
|
||||
$ admin-tools/check-older-versions.sh
|
||||
|
||||
# Make packages and tag
|
||||
|
||||
$ . ./admin-tools/make-dist-older.sh
|
||||
$ pyenv local 3.8.5
|
||||
$ twine check dist/uncompyle6-$VERSION*
|
||||
$ git tag release-python-2.4-$VERSION
|
||||
$ twine check dist/uncompyle6-$VERSION*
|
||||
$ . ./admin-tools/make-dist-newer.sh
|
||||
$ ./admin-tools/make-dist-newer.sh
|
||||
$ twine check dist/uncompyle6-$VERSION*
|
||||
|
||||
# Upload single package and look at Rst Formating
|
||||
# Check package on github
|
||||
|
||||
$ twine check dist/uncompyle6-${VERSION}*
|
||||
$ twine upload dist/uncompyle6-${VERSION}-py3.3.egg
|
||||
$ [[ ! -d /tmp/gittest ]] && mkdir /tmp/gittest; pushd /tmp/gittest
|
||||
$ pyenv local 3.8.3
|
||||
$ pip install -e git://github.com/rocky/python-uncompyle6.git#egg=uncompyle6
|
||||
$ uncompyle6 --help
|
||||
$ pip uninstall uncompyle6
|
||||
$ popd
|
||||
|
||||
# Upload rest of versions
|
||||
|
||||
$ twine upload dist/uncompyle6-${VERSION}*
|
||||
# Release on Github
|
||||
|
||||
Goto https://github.com/rocky/python-uncompyle6/releases
|
||||
|
||||
# Push tags:
|
||||
Now check the *tagged* release. (Checking the untagged release was previously done).
|
||||
|
||||
Todo: turn this into a script in `admin-tools`
|
||||
|
||||
$ pushd /tmp/gittest
|
||||
$ pip install -e git://github.com/rocky/python-uncompyle6.git@$VERSION#egg=uncompyle6
|
||||
$ uncompyle6 --help
|
||||
$ pip uninstall uncompyle6
|
||||
$ popd
|
||||
|
||||
|
||||
# Get onto PyPI
|
||||
|
||||
$ twine upload dist/uncompyle6-${VERSION}*
|
||||
|
||||
|
||||
# Update tags:
|
||||
|
||||
$ git push --tags
|
||||
$ git pull --tags
|
||||
|
||||
# Check on a VM
|
||||
# Move dist files to uploaded
|
||||
|
||||
$ cd /virtual/vagrant/virtual/vagrant/ubuntu-zesty
|
||||
$ vagrant up
|
||||
$ vagrant ssh
|
||||
$ pyenv local 3.5.2
|
||||
$ pip install --upgrade uncompyle6
|
||||
$ exit
|
||||
$ vagrant halt
|
||||
$ mv -v dist/uncompyle6-${VERSION}* dist/uploaded
|
||||
|
@@ -5,4 +5,4 @@ if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
|
||||
echo "This script should be *sourced* rather than run directly through bash"
|
||||
exit 1
|
||||
fi
|
||||
export PYVERSIONS='3.5.9 3.6.10 2.6.9 3.3.7 2.7.17 3.2.6 3.1.5 3.4.10 3.7.6 3.8.1'
|
||||
export PYVERSIONS='3.5.9 3.6.12 2.6.9 3.3.7 2.7.18 3.2.6 3.1.5 3.4.10 3.7.9 3.8.5'
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
PYTHON_VERSION=3.7.6
|
||||
PYTHON_VERSION=3.7.7
|
||||
|
||||
# FIXME put some of the below in a common routine
|
||||
function finish {
|
||||
|
@@ -53,6 +53,7 @@ install:
|
||||
# compiled extensions and are not provided as pre-built wheel packages,
|
||||
# pip will build them from source using the MSVC compiler matching the
|
||||
# target Python version and architecture
|
||||
- "%CMD_IN_ENV% pip install git+git://github.com/rocky/python-uncompyle6.git#egg=uncompyle6-3.6.6"
|
||||
- "%CMD_IN_ENV% pip install -r requirements.txt"
|
||||
|
||||
build_script:
|
||||
|
@@ -1,14 +1,13 @@
|
||||
from uncompyle6 import PYTHON_VERSION
|
||||
from uncompyle6.scanners.tok import Token
|
||||
|
||||
|
||||
def test_token():
|
||||
# Test token formatting of: LOAD_CONST None
|
||||
t = Token("LOAD_CONST", offset=0, attr=None, pattr=None, has_arg=True)
|
||||
expect = " 0 LOAD_CONST None"
|
||||
expect = "0 LOAD_CONST None"
|
||||
# print(t.format())
|
||||
assert t
|
||||
assert t.format() == expect
|
||||
assert t.format().strip() == expect.strip()
|
||||
|
||||
# Make sure equality testing of tokens ignores offset
|
||||
t2 = Token("LOAD_CONST", offset=2, attr=None, pattr=None, has_arg=True)
|
||||
@@ -17,8 +16,8 @@ def test_token():
|
||||
# Make sure formatting of: LOAD_CONST False. We assume False is the 0th index
|
||||
# of co_consts.
|
||||
t = Token("LOAD_CONST", offset=1, attr=False, pattr=False, has_arg=True)
|
||||
expect = " 1 LOAD_CONST False"
|
||||
assert t.format() == expect
|
||||
expect = "1 LOAD_CONST False"
|
||||
assert t.format().strip() == expect.strip()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
16
pytest/testdata/if-2.7.right
vendored
16
pytest/testdata/if-2.7.right
vendored
@@ -1,12 +1,12 @@
|
||||
# Python 2.7
|
||||
# Embedded file name: simple_source/branching/05_if.py
|
||||
|
||||
6 0 LOAD_NAME 0 'True'
|
||||
3 POP_JUMP_IF_FALSE 15 'to 15'
|
||||
L. 6 0 LOAD_NAME 0 'True'
|
||||
3 POP_JUMP_IF_FALSE 15 'to 15'
|
||||
|
||||
7 6 LOAD_NAME 1 'False'
|
||||
9 STORE_NAME 2 'b'
|
||||
12 JUMP_FORWARD 0 'to 15'
|
||||
15_0 COME_FROM 12 '12'
|
||||
15 LOAD_CONST None
|
||||
18 RETURN_VALUE
|
||||
L. 7 6 LOAD_NAME 1 'False'
|
||||
9 STORE_NAME 2 'b'
|
||||
12 JUMP_FORWARD 0 'to 15'
|
||||
15_0 COME_FROM 12 '12'
|
||||
15 LOAD_CONST None
|
||||
18 RETURN_VALUE
|
||||
|
20
pytest/testdata/ifelse-2.7.right
vendored
20
pytest/testdata/ifelse-2.7.right
vendored
@@ -1,15 +1,15 @@
|
||||
# Python 2.7
|
||||
# Embedded file name: simple_source/branching/05_ifelse.py
|
||||
|
||||
3 0 LOAD_NAME 0 'True'
|
||||
3 POP_JUMP_IF_FALSE 15 'to 15'
|
||||
L. 3 0 LOAD_NAME 0 'True'
|
||||
3 POP_JUMP_IF_FALSE 15 'to 15'
|
||||
|
||||
4 6 LOAD_CONST 1
|
||||
9 STORE_NAME 1 'b'
|
||||
12 JUMP_FORWARD 6 'to 21'
|
||||
L. 4 6 LOAD_CONST 1
|
||||
9 STORE_NAME 1 'b'
|
||||
12 JUMP_FORWARD 6 'to 21'
|
||||
|
||||
6 15 LOAD_CONST 2
|
||||
18 STORE_NAME 2 'd'
|
||||
21_0 COME_FROM 12 '12'
|
||||
21 LOAD_CONST None
|
||||
24 RETURN_VALUE
|
||||
L. 6 15 LOAD_CONST 2
|
||||
18 STORE_NAME 2 'd'
|
||||
21_0 COME_FROM 12 '12'
|
||||
21 LOAD_CONST None
|
||||
24 RETURN_VALUE
|
||||
|
@@ -12,8 +12,7 @@ import functools
|
||||
from uncompyle6 import PYTHON_VERSION, PYTHON3, IS_PYPY, code_deparse
|
||||
|
||||
# TODO : I think we can get xdis to support the dis api (python 3 version) by doing something like this there
|
||||
from xdis.bytecode import Bytecode
|
||||
from xdis.main import get_opcode
|
||||
from xdis import Bytecode, get_opcode
|
||||
|
||||
opc = get_opcode(PYTHON_VERSION, IS_PYPY)
|
||||
Bytecode = functools.partial(Bytecode, opc=opc)
|
||||
|
72
setup.py
72
setup.py
@@ -4,40 +4,54 @@ import sys
|
||||
"""Setup script for the 'uncompyle6' distribution."""
|
||||
|
||||
SYS_VERSION = sys.version_info[0:2]
|
||||
if not ((2, 6) <= SYS_VERSION <= (3, 9)):
|
||||
if not ((2, 6) <= SYS_VERSION <= (3, 9)):
|
||||
mess = "Python Release 2.6 .. 3.9 are supported in this code branch."
|
||||
if ((2, 4) <= SYS_VERSION <= (2, 7)):
|
||||
mess += ("\nFor your Python, version %s, use the python-2.4 code/branch." %
|
||||
sys.version[0:3])
|
||||
if (2, 4) <= SYS_VERSION <= (2, 7):
|
||||
mess += (
|
||||
"\nFor your Python, version %s, use the python-2.4 code/branch."
|
||||
% sys.version[0:3]
|
||||
)
|
||||
elif SYS_VERSION < (2, 4):
|
||||
mess += ("\nThis package is not supported for Python version %s."
|
||||
% sys.version[0:3])
|
||||
mess += (
|
||||
"\nThis package is not supported for Python version %s." % sys.version[0:3]
|
||||
)
|
||||
print(mess)
|
||||
raise Exception(mess)
|
||||
|
||||
from __pkginfo__ import \
|
||||
author, author_email, install_requires, \
|
||||
license, long_description, classifiers, \
|
||||
entry_points, modname, py_modules, \
|
||||
short_desc, VERSION, web, \
|
||||
zip_safe
|
||||
from __pkginfo__ import (
|
||||
author,
|
||||
author_email,
|
||||
install_requires,
|
||||
license,
|
||||
long_description,
|
||||
classifiers,
|
||||
entry_points,
|
||||
modname,
|
||||
py_modules,
|
||||
short_desc,
|
||||
VERSION,
|
||||
web,
|
||||
zip_safe,
|
||||
)
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
author = author,
|
||||
author_email = author_email,
|
||||
classifiers = classifiers,
|
||||
description = short_desc,
|
||||
entry_points = entry_points,
|
||||
install_requires = install_requires,
|
||||
license = license,
|
||||
long_description = long_description,
|
||||
long_description_content_type = "text/x-rst",
|
||||
name = modname,
|
||||
packages = find_packages(),
|
||||
py_modules = py_modules,
|
||||
test_suite = 'nose.collector',
|
||||
url = web,
|
||||
tests_require = ['nose>=1.0'],
|
||||
version = VERSION,
|
||||
zip_safe = zip_safe)
|
||||
author=author,
|
||||
author_email=author_email,
|
||||
classifiers=classifiers,
|
||||
description=short_desc,
|
||||
entry_points=entry_points,
|
||||
install_requires=install_requires,
|
||||
license=license,
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/x-rst",
|
||||
name=modname,
|
||||
packages=find_packages(),
|
||||
py_modules=py_modules,
|
||||
test_suite="nose.collector",
|
||||
url=web,
|
||||
tests_require=["nose>=1.0"],
|
||||
version=VERSION,
|
||||
zip_safe=zip_safe,
|
||||
)
|
||||
|
5
test/.gitignore
vendored
5
test/.gitignore
vendored
@@ -1,3 +1,8 @@
|
||||
/.coverage
|
||||
/.python-version
|
||||
/nohup.out
|
||||
/pycdc
|
||||
/test_pycdc_tests.sh
|
||||
/test_uncompyle2.py
|
||||
/test_unpy33.py
|
||||
/test_unpy37.py
|
||||
|
@@ -78,7 +78,7 @@ check-3.8: check-bytecode
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.8 --syntax-verify $(COMPILE)
|
||||
|
||||
# FIXME
|
||||
#: this is called when running under pypy3.5-5.8.0 or pypy2-5.6.0
|
||||
#: this is called when running under pypy3.5-5.8.0, pypy2-5.6.0, or pypy3.6-7.3.0
|
||||
5.8 5.6:
|
||||
|
||||
#: Check deparsing only, but from a different Python version
|
||||
@@ -95,12 +95,19 @@ check-bytecode-2:
|
||||
--bytecode-2.5 --bytecode-2.6 --bytecode-2.7 --bytecode-pypy2.7
|
||||
|
||||
#: Check deparsing bytecode 3.x only
|
||||
# check-bytecode-3:
|
||||
# $(PYTHON) test_pythonlib.py \
|
||||
# --bytecode-3.0 \
|
||||
# --bytecode-3.1 --bytecode-3.2 --bytecode-3.3 \
|
||||
# --bytecode-3.4 --bytecode-3.5 --bytecode-3.6 \
|
||||
# --bytecode-3.7 \
|
||||
# --bytecode-pypy3.2 --bytecode-pypy3.6 --bytecode-3.8
|
||||
|
||||
# FIXME: Until we shaked out problems with xdis...
|
||||
check-bytecode-3:
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.0 \
|
||||
--bytecode-3.1 --bytecode-3.2 --bytecode-3.3 \
|
||||
$(PYTHON) test_pythonlib.py \
|
||||
--bytecode-3.4 --bytecode-3.5 --bytecode-3.6 \
|
||||
--bytecode-3.7 \
|
||||
--bytecode-pypy3.2 --bytecode-pypy3.6 --bytecode-3.8
|
||||
--bytecode-3.7 --bytecode-3.8
|
||||
|
||||
#: Check deparsing on selected bytecode 3.x
|
||||
check-bytecode-3-short:
|
||||
@@ -339,8 +346,8 @@ check-bytecode-pypy3.6: 7.1
|
||||
$(PYTHON) test_pythonlib.py --bytecode-pypy3.6 --verify
|
||||
|
||||
#: PyPy 5.0.x with Python 3.6.9
|
||||
check-bytecode-pypy3.6: 7.2
|
||||
7.2:
|
||||
check-bytecode-pypy3.6: 7.2 7.3
|
||||
7.3 7.2:
|
||||
$(PYTHON) test_pythonlib.py --bytecode-pypy3.6-run --verify-run
|
||||
$(PYTHON) test_pythonlib.py --bytecode-pypy3.6 --verify
|
||||
|
||||
|
@@ -3,14 +3,22 @@
|
||||
"""
|
||||
import os, sys, py_compile
|
||||
|
||||
assert len(sys.argv) >= 2
|
||||
assert (2 <= len(sys.argv) <= 4)
|
||||
version = sys.version[0:3]
|
||||
vers = sys.version_info[:2]
|
||||
if sys.argv[1] in ("--run", "-r"):
|
||||
suffix = "_run"
|
||||
py_source = sys.argv[2:]
|
||||
i = 2
|
||||
else:
|
||||
suffix = ""
|
||||
py_source = sys.argv[1:]
|
||||
i = 1
|
||||
try:
|
||||
optimize = int(sys.argv[-1])
|
||||
py_source = sys.argv[i:-1]
|
||||
except:
|
||||
optimize = 2
|
||||
|
||||
for path in py_source:
|
||||
short = os.path.basename(path)
|
||||
@@ -19,6 +27,10 @@ for path in py_source:
|
||||
else:
|
||||
cfile = "bytecode_%s%s/%s" % (version, suffix, short) + "c"
|
||||
print("byte-compiling %s to %s" % (path, cfile))
|
||||
py_compile.compile(path, cfile)
|
||||
if isinstance(version, str) or version >= (2, 6, 0):
|
||||
optimize = optimize
|
||||
if vers > (3, 1):
|
||||
py_compile.compile(path, cfile, optimize=optimize)
|
||||
else:
|
||||
py_compile.compile(path, cfile)
|
||||
if vers >= (2, 6):
|
||||
os.system("../bin/uncompyle6 -a -T %s" % cfile)
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_2.4_run/01_for_else_try_else.pyc
Normal file
BIN
test/bytecode_2.4_run/01_for_else_try_else.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_2.7/01_module_doc.pyc
Normal file
BIN
test/bytecode_2.7/01_module_doc.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_2.7_run/01_for_else_try_else.pyc
Normal file
BIN
test/bytecode_2.7_run/01_for_else_try_else.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_2.7_run/03_doc_assign.pyc
Normal file
BIN
test/bytecode_2.7_run/03_doc_assign.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_3.1_run/03_doc_assign.pyc
Normal file
BIN
test/bytecode_3.1_run/03_doc_assign.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.3_run/03_doc_assign.pyc-notyet
Normal file
BIN
test/bytecode_3.3_run/03_doc_assign.pyc-notyet
Normal file
Binary file not shown.
BIN
test/bytecode_3.3_run/03_if_elif.pyc
Normal file
BIN
test/bytecode_3.3_run/03_if_elif.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.5_run/03_if_elif.pyc
Normal file
BIN
test/bytecode_3.5_run/03_if_elif.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_3.6_run/03_doc_assign.pyc-notyet
Normal file
BIN
test/bytecode_3.6_run/03_doc_assign.pyc-notyet
Normal file
Binary file not shown.
BIN
test/bytecode_3.6_run/03_if_elif.pyc
Normal file
BIN
test/bytecode_3.6_run/03_if_elif.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_3.7/03_else_removal.pyc
Normal file
BIN
test/bytecode_3.7/03_else_removal.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_3.7_run/01_for_else_try_else.pyc
Normal file
BIN
test/bytecode_3.7_run/01_for_else_try_else.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.7_run/03_if_elif.pyc
Normal file
BIN
test/bytecode_3.7_run/03_if_elif.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_3.7_run/10_async.pyc
Normal file
BIN
test/bytecode_3.7_run/10_async.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.8/03_else_removal.pyc
Normal file
BIN
test/bytecode_3.8/03_else_removal.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_3.8_run/10_async.pyc
Normal file
BIN
test/bytecode_3.8_run/10_async.pyc
Normal file
Binary file not shown.
@@ -3,32 +3,55 @@
|
||||
function displaytime {
|
||||
printf "ran in "
|
||||
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 '
|
||||
((D=T/60/60/24))
|
||||
((H=T/60/60%24))
|
||||
((M=T/60%60))
|
||||
((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
|
||||
}
|
||||
|
||||
. ../admin-tools/pyenv-newer-versions
|
||||
bs=${BASH_SOURCE[0]}
|
||||
if [[ $0 != $bs ]] ; then
|
||||
echo "This script should not be *sourced* but run through bash"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mydir=$(dirname $bs)
|
||||
cd $mydir
|
||||
|
||||
branch=$(cat ../.git/HEAD | cut -d'/' -f 3)
|
||||
if [[ $branch == 'python-2.4' ]]; then
|
||||
. ../admin-tools/pyenv-older-versions
|
||||
elif [[ $branch == 'master' ]]; then
|
||||
. ../admin-tools/pyenv-newer-versions
|
||||
else
|
||||
echo &1>2 "Error git branch should either be 'master' or 'python-2.4'; got: '$branch'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MAIN="test_pyenvlib.py"
|
||||
|
||||
USER=${USER:-rocky}
|
||||
EMAIL=${EMAIL:-rb@dustyfeet.com}
|
||||
WHAT="uncompyle6 ${MAIN}"
|
||||
MAX_TESTS=${MAX_TESTS:-800}
|
||||
export BATCH=1
|
||||
|
||||
typeset -i RUN_STARTTIME=$(date +%s)
|
||||
|
||||
# PYVERSIONS="3.5.6"
|
||||
actual_versions=""
|
||||
MAILBODY=/tmp/${MAIN}-mailbody-$$.txt
|
||||
# for VERSION in 3.3.7 ; do
|
||||
for VERSION in $PYVERSIONS ; do
|
||||
typeset -i rc=0
|
||||
LOGFILE=/tmp/pyenvlib-$VERSION-$$.log
|
||||
LOGFILE=/tmp/${MAIN}-$VERSION-$$.log
|
||||
|
||||
case "$VERSION" in
|
||||
3.7.6 | 3.8.1 | 3.1.5 | 3.0.1 )
|
||||
3.7.8 | 3.8.5 | 3.1.5 | 3.0.1 )
|
||||
continue
|
||||
;;
|
||||
3.5.9 )
|
||||
@@ -43,8 +66,16 @@ for VERSION in $PYVERSIONS ; do
|
||||
3.4.10 )
|
||||
MAX_TESTS=800
|
||||
;;
|
||||
3.6.10 )
|
||||
MAX_TESTS=1300 # about 2139 exist
|
||||
3.6.11 )
|
||||
# MAX_TESTS=1300 # about 2139 exist
|
||||
# fails on _pyio.cpython-36.opt-1.pyc
|
||||
MAX_TESTS=34
|
||||
;;
|
||||
2.4.6 )
|
||||
MAX_TESTS=600
|
||||
;;
|
||||
2.5.6 )
|
||||
MAX_TESTS=600
|
||||
;;
|
||||
2.6.9 )
|
||||
MAX_TESTS=1300
|
||||
@@ -58,11 +89,13 @@ for VERSION in $PYVERSIONS ; do
|
||||
|
||||
if ! pyenv local $VERSION ; then
|
||||
rc=1
|
||||
mailbody_line="pyenv local $VERSION not installed"
|
||||
echo $mailbody_line >> $MAILBODY
|
||||
else
|
||||
echo Python Version $(pyenv local) > $LOGFILE
|
||||
echo "" >> $LOGFILE
|
||||
typeset -i ALL_FILES_STARTTIME=$(date +%s)
|
||||
cmd="python ./test_pyenvlib.py --max ${MAX_TESTS} --syntax-verify --$VERSION"
|
||||
cmd="python ./${MAIN} --max ${MAX_TESTS} --syntax-verify --$VERSION"
|
||||
echo "$cmd" >>$LOGFILE 2>&1
|
||||
$cmd >>$LOGFILE 2>&1
|
||||
rc=$?
|
||||
@@ -72,20 +105,25 @@ for VERSION in $PYVERSIONS ; do
|
||||
|
||||
typeset -i ALL_FILES_ENDTIME=$(date +%s)
|
||||
(( time_diff = ALL_FILES_ENDTIME - ALL_FILES_STARTTIME))
|
||||
displaytime $time_diff >> $LOGFILE
|
||||
time_str=$(displaytime $time_diff)
|
||||
echo ${time_str}. >> $LOGFILE
|
||||
fi
|
||||
|
||||
SUBJECT_PREFIX="pyenv weak verify (max $MAX_TESTS) for"
|
||||
SUBJECT_PREFIX="$WHAT (max $MAX_TESTS) for"
|
||||
if ((rc == 0)); then
|
||||
mailbody_line="Python $VERSION ok; ${time_str}."
|
||||
tail -v $LOGFILE | mail -s "$SUBJECT_PREFIX $VERSION ok" ${USER}@localhost
|
||||
else
|
||||
mailbody_line="Python $VERSION failed; ${time_str}."
|
||||
tail -v $LOGFILE | mail -s "$SUBJECT_PREFIX $VERSION not ok" ${USER}@localhost
|
||||
tail -v $LOGFILE | mail -s "$SUBJECT_PREFIX $VERSION not ok" ${EMAIL}
|
||||
tail -v $LOGFILE | mail -s "$HOST $SUBJECT_PREFIX $VERSION not ok" ${EMAIL}
|
||||
fi
|
||||
echo $mailbody_line >> $MAILBODY
|
||||
rm .python-version
|
||||
done
|
||||
|
||||
typeset -i RUN_ENDTIME=$(date +%s)
|
||||
(( time_diff = RUN_ENDTIME - RUN_STARTTIME))
|
||||
elapsed_time=$(displaytime $time_diff)
|
||||
echo "Run complete $elapsed_time for versions $actual_versions" | mail -s "pyenv weak verify in $elapsed_time" ${EMAIL}
|
||||
echo "${WHAT} complete; ${elapsed_time}." >> $MAILBODY
|
||||
cat $MAILBODY | mail -s "$HOST $WHAT ${elapsed_time}." ${EMAIL}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
from uncompyle6.main import decompile
|
||||
from xdis.magics import sysinfo2float
|
||||
from xdis import sysinfo2float
|
||||
import sys, inspect
|
||||
|
||||
def uncompyle_test():
|
17
test/simple_source/bug14/01_for_else_try_else.py
Normal file
17
test/simple_source/bug14/01_for_else_try_else.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Adapted from 1.4 anydbm
|
||||
"""This program is self-checking!"""
|
||||
def scan(items):
|
||||
for i in items:
|
||||
try:
|
||||
5 / i
|
||||
except:
|
||||
continue
|
||||
else:
|
||||
break
|
||||
else:
|
||||
return 2
|
||||
return i
|
||||
|
||||
assert scan((0, 1)) == 1
|
||||
assert scan((0, 0)) == 2
|
||||
assert scan((3, 2, 1)) == 3
|
9
test/simple_source/bug27+/01_module_doc.py
Normal file
9
test/simple_source/bug27+/01_module_doc.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# From 2.7.17 test_bdb.py
|
||||
# The problem was detecting a docstring at the begining of the module
|
||||
# It must be detected and change'd or else the "from __future__" below
|
||||
# is invalid.
|
||||
# Note that this has to be compiled with optimation < 2 or else optimization
|
||||
# will remove the docstring
|
||||
"""Rational, infinite-precision, real numbers."""
|
||||
|
||||
from __future__ import division
|
27
test/simple_source/bug27+/03_doc_assign.py
Normal file
27
test/simple_source/bug27+/03_doc_assign.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# From 2.7 test_descr.py
|
||||
# Testing __doc__ descriptor...
|
||||
# The bug in decompilation was erroneously matching
|
||||
# __doc__ = as a docstring
|
||||
|
||||
"""This program is self-checking!"""
|
||||
|
||||
def test_doc_descriptor():
|
||||
# Testing __doc__ descriptor...
|
||||
# Python SF bug 542984
|
||||
class DocDescr(object):
|
||||
def __get__(self, object, otype):
|
||||
if object:
|
||||
object = object.__class__.__name__ + ' instance'
|
||||
if otype:
|
||||
otype = otype.__name__
|
||||
return 'object=%s; type=%s' % (object, otype)
|
||||
class OldClass:
|
||||
__doc__ = DocDescr()
|
||||
class NewClass(object):
|
||||
__doc__ = DocDescr()
|
||||
assert OldClass.__doc__ == 'object=None; type=OldClass'
|
||||
assert OldClass().__doc__ == 'object=OldClass instance; type=OldClass'
|
||||
assert NewClass.__doc__ == 'object=None; type=NewClass'
|
||||
assert NewClass().__doc__ == 'object=NewClass instance; type=NewClass'
|
||||
|
||||
test_doc_descriptor()
|
@@ -66,6 +66,14 @@ def div(a: dict(type=float, help='the dividend'),
|
||||
"""Divide a by b"""
|
||||
return a / b
|
||||
|
||||
# From 3.7.6 functools.py
|
||||
# Bug is in picking up the annotation.
|
||||
def f(a:"This is a new annotation"):
|
||||
"""This is a test"""
|
||||
assert f.__annotations__['a'] == "This is a new annotation"
|
||||
|
||||
f(5)
|
||||
|
||||
class TestSignatureObject1():
|
||||
def test_signature_on_wkwonly(self):
|
||||
def test(*, a:float, b:str, c:str = 'test', **kwargs: int) -> int:
|
||||
|
@@ -1,6 +1,8 @@
|
||||
# Python 3.3+
|
||||
#
|
||||
# From Python 3.3.6 hmac.py
|
||||
# Problem was getting wrong placement of positional args.
|
||||
# In 3.6+ paramter handling changes
|
||||
# In 3.6+ parameter handling changes
|
||||
|
||||
# RUNNABLE!
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
# Bug was code not knowing which Python versions
|
||||
# have kwargs coming before positional args in code.
|
||||
|
||||
"""This program is self-checking!"""
|
||||
# RUNNABLE!
|
||||
|
||||
def tometadata(self, metadata, schema, Table, args, name=None):
|
||||
|
@@ -1,6 +1,9 @@
|
||||
# 3.6+ type annotations on variables
|
||||
from typing import List
|
||||
|
||||
# This test program is part of the uncompyle6 test suite
|
||||
# tests STORE_ANNOTATION and SETUP_ANOTATIONS
|
||||
|
||||
# RUNNABLE!
|
||||
y = 2
|
||||
x: bool
|
||||
|
@@ -6,3 +6,11 @@ def make_arange(n):
|
||||
|
||||
async def run(m):
|
||||
return [i async for i in m]
|
||||
|
||||
# From 3.7.6 test_coroutines.py
|
||||
async def run_list(pair, f):
|
||||
return [i for pair in p async for i in f]
|
||||
|
||||
# FIXME: add this. It works in decompyle3
|
||||
# async def run_gen():
|
||||
# return (i async for i in f if 0 < i < 4)
|
||||
|
12
test/simple_source/bug37/03_else_removal.py
Normal file
12
test/simple_source/bug37/03_else_removal.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# From python3.8/distutils/version.py with optimization -O2
|
||||
# The bug was that the other "else" constant propagated removed.
|
||||
|
||||
# NOTE: this program needs to be compile with optimization
|
||||
def _cmp (b, c):
|
||||
if b:
|
||||
if c:
|
||||
return 0
|
||||
else:
|
||||
return 1
|
||||
else:
|
||||
assert False, "never get here"
|
@@ -1,23 +0,0 @@
|
||||
# from 3.7 test_contextlib_async.py
|
||||
# Bugs were not adding "async" when a function is a decorator,
|
||||
# and a misaligment when using "async with as".
|
||||
@_async_test
|
||||
async def test_enter(self):
|
||||
self.assertIs(await manager.__aenter__(), manager)
|
||||
|
||||
async with manager as context:
|
||||
async with woohoo() as x:
|
||||
x = 1
|
||||
y = 2
|
||||
assert manager is context
|
||||
|
||||
# From 3.7.6 test_coroutines.py
|
||||
# Bug was different form of code for "async with" below
|
||||
class CoroutineTest():
|
||||
def test_with_8(self):
|
||||
CNT = 0
|
||||
async def foo():
|
||||
nonlocal CNT
|
||||
async with CM():
|
||||
CNT += 1
|
||||
return
|
87
test/simple_source/bug37/04_grammar.py
Normal file
87
test/simple_source/bug37/04_grammar.py
Normal file
@@ -0,0 +1,87 @@
|
||||
# From test_grammar.py
|
||||
# RUNNABLE!
|
||||
def check_syntax_error(statement):
|
||||
try:
|
||||
compile(statement, '<test string>', 'exec')
|
||||
except SyntaxError:
|
||||
return
|
||||
assert False
|
||||
|
||||
def test_yield():
|
||||
# Requires parentheses as call argument
|
||||
def g():
|
||||
f((yield 1), 1)
|
||||
def g():
|
||||
f((yield from ()))
|
||||
def g():
|
||||
f((yield from ()), 1)
|
||||
def g():
|
||||
f((yield 1))
|
||||
|
||||
# Allowed as standalone statement
|
||||
def g():
|
||||
yield 1
|
||||
|
||||
def g():
|
||||
yield from ()
|
||||
|
||||
# Allowed as RHS of assignment
|
||||
def g():
|
||||
x = yield 1
|
||||
|
||||
def g():
|
||||
x = yield from ()
|
||||
|
||||
# Ordinary yield accepts implicit tuples
|
||||
def g():
|
||||
yield 1, 1
|
||||
|
||||
def g():
|
||||
x = yield 1, 1
|
||||
|
||||
# 'yield from' does not
|
||||
check_syntax_error("def g(): yield from (), 1")
|
||||
check_syntax_error("def g(): x = yield from (), 1")
|
||||
# Requires parentheses as subexpression
|
||||
def g():
|
||||
1, (yield 1)
|
||||
|
||||
def g():
|
||||
1, (yield from ())
|
||||
|
||||
check_syntax_error("def g(): 1, yield 1")
|
||||
check_syntax_error("def g(): 1, yield from ()")
|
||||
# Requires parentheses as call argument
|
||||
def g():
|
||||
f((yield 1))
|
||||
|
||||
def g():
|
||||
f((yield 1), 1)
|
||||
|
||||
def g():
|
||||
f((yield from ()))
|
||||
|
||||
def g():
|
||||
f((yield from ()), 1)
|
||||
|
||||
check_syntax_error("def g(): f(yield 1)")
|
||||
check_syntax_error("def g(): f(yield 1, 1)")
|
||||
check_syntax_error("def g(): f(yield from ())")
|
||||
check_syntax_error("def g(): f(yield from (), 1)")
|
||||
# Not allowed at top level
|
||||
check_syntax_error("yield")
|
||||
check_syntax_error("yield from")
|
||||
# Not allowed at class scope
|
||||
check_syntax_error("class foo:yield 1")
|
||||
check_syntax_error("class foo:yield from ()")
|
||||
# Check annotation refleak on SyntaxError
|
||||
check_syntax_error("def g(a:(yield)): pass")
|
||||
|
||||
test_yield()
|
||||
|
||||
# From test_types.py
|
||||
# Bug was needing parens around (yield 2)
|
||||
def gen_func():
|
||||
yield 1
|
||||
return (yield 2)
|
||||
gen = gen_func()
|
70
test/simple_source/bug37/10_async.py
Normal file
70
test/simple_source/bug37/10_async.py
Normal file
@@ -0,0 +1,70 @@
|
||||
# from 3.7 test_contextlib_async.py
|
||||
# Bugs were not adding "async" when a function is a decorator,
|
||||
# and a misaligment when using "async with ... as".
|
||||
|
||||
"""This program is self-checking!"""
|
||||
import asyncio
|
||||
from contextlib import asynccontextmanager, AbstractAsyncContextManager
|
||||
import functools
|
||||
|
||||
|
||||
def _async_test(func):
|
||||
"""Decorator to turn an async function into a test case."""
|
||||
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
coro = func(*args, **kwargs)
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
try:
|
||||
return loop.run_until_complete(coro)
|
||||
finally:
|
||||
loop.close()
|
||||
asyncio.set_event_loop(None)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
state = []
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def woohoo():
|
||||
state.append(1)
|
||||
yield 42
|
||||
state.append(999)
|
||||
|
||||
|
||||
@_async_test
|
||||
async def test_enter():
|
||||
class DefaultEnter(AbstractAsyncContextManager):
|
||||
async def __aexit__(*args):
|
||||
return
|
||||
# await super().__aexit__(*args)
|
||||
|
||||
manager = DefaultEnter()
|
||||
got_manager = await manager.__aenter__()
|
||||
# print(got_manager, manager)
|
||||
assert got_manager is manager
|
||||
|
||||
async with manager as context:
|
||||
async with woohoo() as x:
|
||||
x = 1
|
||||
y = 2
|
||||
assert manager is context
|
||||
|
||||
|
||||
# From 3.7.6 test_coroutines.py
|
||||
# Bug was different form of code for "async with" below
|
||||
class CoroutineTest:
|
||||
def test_with_8(self):
|
||||
CNT = 0
|
||||
|
||||
async def foo():
|
||||
nonlocal CNT
|
||||
async with CM():
|
||||
CNT += 1
|
||||
return
|
||||
|
||||
|
||||
test_enter()
|
@@ -17,9 +17,9 @@ def ybug(g):
|
||||
# From 3.5.1 _wakrefset.py
|
||||
#
|
||||
# 3.5:
|
||||
# withstmt ::= expr SETUP_WITH POP_TOP suite_stmts_opt
|
||||
# POP_BLOCK LOAD_CONST COME_FROM
|
||||
# WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
||||
# with ::= expr SETUP_WITH POP_TOP suite_stmts_opt
|
||||
# POP_BLOCK LOAD_CONST COME_FROM
|
||||
# WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
||||
|
||||
|
||||
def __iter__(self, IterationGuard):
|
||||
|
@@ -7,3 +7,40 @@ def readline (self):
|
||||
continue
|
||||
|
||||
return
|
||||
|
||||
# From 2.4.6 sre.py
|
||||
# Bug has to do with "break" not being recognized
|
||||
# and is a JUMP_FORWARD.
|
||||
def _parse(a, b, source, state):
|
||||
while 1:
|
||||
if b:
|
||||
while 1:
|
||||
break
|
||||
else:
|
||||
raise
|
||||
|
||||
def _parse2(source, state):
|
||||
while 1:
|
||||
if a:
|
||||
if b:
|
||||
while 1:
|
||||
this = 1
|
||||
break
|
||||
continue
|
||||
|
||||
while 1:
|
||||
if b:
|
||||
break
|
||||
|
||||
x = 3
|
||||
|
||||
# Bug was in 2.3 decompilation
|
||||
def _parse3(source, state):
|
||||
while 1:
|
||||
if a:
|
||||
if b:
|
||||
x = 1
|
||||
while 1:
|
||||
if a:
|
||||
break
|
||||
raise
|
||||
|
@@ -1,11 +1,13 @@
|
||||
# 2.6.9 symbols.py
|
||||
# Bug in 2.6 is having multple COME_FROMs due to the
|
||||
# "and" in the "if" clause
|
||||
|
||||
# RUNNABLE
|
||||
if __name__:
|
||||
if __file__ and __name__:
|
||||
pass
|
||||
elif __name__:
|
||||
pass
|
||||
elif not __name__:
|
||||
assert False
|
||||
|
||||
# 2.6.9 transformer.py
|
||||
# Bug in 2.6 is multple COME_FROMs as a result
|
||||
@@ -21,3 +23,20 @@ elif __file__:
|
||||
assert __name__ or __file__
|
||||
else:
|
||||
pass
|
||||
|
||||
# From 3.3.7 test_binop.py
|
||||
# Bug was in ifelsestmt(c) ensuring b+=5 is not in "else"
|
||||
# Also note: ifelsetmtc should not have been used since this
|
||||
# this is not in a loop!
|
||||
def __floordiv__(a, b):
|
||||
if a:
|
||||
b += 1
|
||||
elif not b:
|
||||
return a
|
||||
b += 5
|
||||
return b
|
||||
|
||||
assert __floordiv__(1, 1) == 7
|
||||
assert __floordiv__(1, 0) == 6
|
||||
assert __floordiv__(0, 3) == 8
|
||||
assert __floordiv__(0, 0) == 0
|
||||
|
@@ -16,3 +16,25 @@ def withas_bug(self, nested, a, b):
|
||||
with self.assertRaises(ZeroDivisionError):
|
||||
with nested(a(), b()) as (x, y):
|
||||
1 // 0
|
||||
|
||||
# From 3.7.7 test_functools.py
|
||||
# Bug is a unreachable code after "return"
|
||||
def test_invalid_registrations(x):
|
||||
return
|
||||
with x:
|
||||
x = 1
|
||||
|
||||
# From 3.7.7 test_re.py
|
||||
# Bug was hooking in c_with.
|
||||
def test_re_tests(tests):
|
||||
for t in tests:
|
||||
with a:
|
||||
continue
|
||||
|
||||
# Adapted from 3.8 distutils/command/config.py
|
||||
# In 3.8 the problem was in handling "with .. as" code
|
||||
def _gen_temp_sourcefile(x, a, headers, lang):
|
||||
with x as y:
|
||||
if a:
|
||||
y = 2
|
||||
return 5
|
||||
|
@@ -8,7 +8,7 @@ b = [4, 5, 6]
|
||||
del b[1]
|
||||
del b[:]
|
||||
|
||||
# del_stmt ::= expr expr DELETE_SLICE+1
|
||||
# delete ::= expr expr DELETE_SLICE+1
|
||||
l = [None] * 10
|
||||
del l[-2:]
|
||||
|
||||
|
2
test/stdlib/.gitignore
vendored
2
test/stdlib/.gitignore
vendored
@@ -1 +1,3 @@
|
||||
/.python-version
|
||||
/runun33.sh
|
||||
/runun7.sh
|
||||
|
@@ -45,7 +45,6 @@ SKIP_TESTS=(
|
||||
[test_grammar.py]=1 # Too many stmts. Handle large stmts
|
||||
[test_grp.py]=1 # Long test - might work Control flow?
|
||||
[test_pep247.py]=1 # Long test - might work? Control flow?
|
||||
[test_pwd.py]=1 # Long test - might work? Control flow?
|
||||
[test_socketserver.py]=1 # -- test takes too long to run: 40 seconds
|
||||
[test_threading.py]=1 # test takes too long to run: 11 seconds
|
||||
[test_thread.py]=1 # test takes too long to run: 36 seconds
|
||||
|
@@ -55,12 +55,9 @@ SKIP_TESTS=(
|
||||
[test_ossaudiodev.py]=1 # it fails on its own
|
||||
[test_pdb.py]=1 # Line-number specific
|
||||
[test_pep277.py]=1 # it fails on its own
|
||||
[test_pep352.py]=1 # Investigate
|
||||
[test_plistlib.py]=1 # it fails on its own
|
||||
[test_pwd.py]=1 # Long test - might work? Control flow?
|
||||
[test_pyclbr.py]=1 # Investigate
|
||||
[test_rgbimg.py]=1 # it fails on its own
|
||||
[test_queue.py]=1 # Control flow?
|
||||
[test_scriptpackages.py]=1 # it fails on its own
|
||||
[test_socketserver.py]=1 # Too long to run - 42 seconds
|
||||
[test_sqlite.py]=1 # it fails on its own
|
||||
@@ -81,6 +78,6 @@ SKIP_TESTS=(
|
||||
)
|
||||
# About 265 tests in 14 minutes
|
||||
|
||||
if (( batch )) ; then
|
||||
if (( BATCH )) ; then
|
||||
SKIP_TESTS[test_doctest.py]=1 # Fails on ppc64le
|
||||
fi
|
||||
|
@@ -1,4 +1,11 @@
|
||||
SKIP_TESTS=(
|
||||
# ifelsestmt is borked in:
|
||||
# if filename == 'srcfile':
|
||||
# return srcfile
|
||||
# if filename == 'destfile':
|
||||
# return destfile
|
||||
# assert 0 # shouldn't reach here.
|
||||
[test_shutil.py]=1
|
||||
|
||||
[test___all__.py]=1 # it fails on its own
|
||||
[test___all__.py]=1 # it fails on its own
|
||||
@@ -52,13 +59,12 @@ SKIP_TESTS=(
|
||||
[test_ossaudiodev.py]=1 # it fails on its own
|
||||
|
||||
[test_pep277.py]=1 # it fails on its own
|
||||
[test_pep352.py]=1 # Investigate
|
||||
[test_pyclbr.py]=1 # Investigate
|
||||
[test_pwd.py]=1 # Long test - might work? Control flow?
|
||||
[test_py3kwarn.py]=1 # it fails on its own
|
||||
|
||||
[test_scriptpackages.py]=1 # it fails on its own
|
||||
[test_select.py]=1 # test takes too long to run: 11 seconds
|
||||
|
||||
[test_socket.py]=1 # test takes too long to run: 12 seconds
|
||||
[test_startfile.py]=1 # it fails on its own
|
||||
[test_structmembers.py]=1 # it fails on its own
|
||||
@@ -85,7 +91,7 @@ SKIP_TESTS=(
|
||||
)
|
||||
# About 305 unit-test files in about 12 minutes
|
||||
|
||||
if (( batch )) ; then
|
||||
if (( BATCH )) ; then
|
||||
# Fails in crontab environment?
|
||||
# Figure out what's up here
|
||||
SKIP_TESTS[test_aifc.py]=1
|
||||
|
@@ -1,4 +1,6 @@
|
||||
SKIP_TESTS=(
|
||||
[test_cgi.py]=1 # FIXME: Works on c90ff51
|
||||
|
||||
[test_bsddb3.py]=1 # test takes too long to run: 110 seconds
|
||||
[test_compile.py]=1 # Code introspects on co_consts in a non-decompilable way
|
||||
[test_curses.py]=1 # Possibly fails on its own but not detected
|
||||
@@ -17,7 +19,6 @@ SKIP_TESTS=(
|
||||
[test_modulefinder.py]=1 # FIX
|
||||
[test_multiprocessing.py]=1 # On uncompyle2, takes 24 secs
|
||||
[test_poll.py]=1 # test takes too long to run: 11 seconds
|
||||
[test_pwd.py]=1 # Takes too long
|
||||
[test_regrtest.py]=1 #
|
||||
[test_runpy.py]=1 # Long and fails on its own
|
||||
[test_select.py]=1 # Runs okay but takes 11 seconds
|
||||
@@ -25,6 +26,7 @@ SKIP_TESTS=(
|
||||
[test_ssl.py]=1 #
|
||||
[test_subprocess.py]=1 # Runs ok but takes 22 seconds
|
||||
[test_sys_settrace.py]=1 # Line numbers are expected to be different
|
||||
|
||||
[test_tokenize.py]=1 # test takes too long to run: 19 seconds
|
||||
[test_traceback.py]=1 # Line numbers change - duh.
|
||||
[test_unicode.py]=1 # Too long to run 11 seconds
|
||||
@@ -34,7 +36,7 @@ SKIP_TESTS=(
|
||||
)
|
||||
# 334 unit-test files in about 15 minutes
|
||||
|
||||
if (( batch )) ; then
|
||||
if (( BATCH )) ; then
|
||||
# Fails in crontab environment?
|
||||
# Figure out what's up here
|
||||
SKIP_TESTS[test_array.py]=1
|
||||
@@ -43,6 +45,7 @@ if (( batch )) ; then
|
||||
SKIP_TESTS[test_doctest2.py]=1 # a POWER thing?
|
||||
SKIP_TESTS[test_httplib.py]=1 # Ok, but POWER has problems with this
|
||||
SKIP_TESTS[test_pdb.py]=1 # Ok, but POWER has problems with this
|
||||
SKIP_TESTS[test_tarfile.py]=1 # test can take over 15 seconds to run on an overloaded POWER7 system
|
||||
|
||||
# SyntaxError: Non-ASCII character '\xdd' in file test_base64.py on line 153, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
|
||||
SKIP_TESTS[test_base64.py]=1
|
||||
|
@@ -17,8 +17,6 @@ SKIP_TESTS=(
|
||||
[test_peepholer.py]=1
|
||||
[test_pep352.py]=1
|
||||
|
||||
[test_quopri.py]=1 # TypeError: Can't convert 'bytes' object to str implicitly
|
||||
|
||||
[test_runpy.py]=1
|
||||
|
||||
[test_ssl.py]=1 # too installation specific
|
||||
@@ -31,9 +29,8 @@ SKIP_TESTS=(
|
||||
|
||||
)
|
||||
|
||||
if (( batch )) ; then
|
||||
if (( BATCH )) ; then
|
||||
# Fails in crontab environment?
|
||||
# Figure out what's up here
|
||||
SKIP_TESTS[test_exception_variations.py]=1
|
||||
SKIP_TESTS[test_quopri.py]=1
|
||||
fi
|
||||
|
@@ -1,7 +1,19 @@
|
||||
SKIP_TESTS=(
|
||||
[test_atexit.py]=1 # The atexit test starting at 3.3 looks for specific comments in error lines
|
||||
# FIXME: Did this work sometime in the past ?
|
||||
# for elem in g(s):
|
||||
# if not tgt and isOdd(elem): continue
|
||||
# is erroneously:
|
||||
# for elem in g(s):
|
||||
# if tgt or isOdd(elem):
|
||||
# pass
|
||||
# else:
|
||||
# tgt.append(elem)
|
||||
[test_itertools.py]=1
|
||||
|
||||
[test_buffer.py]=1 # parse error
|
||||
[test_buffer.py]=1 # FIXME: Works on c90ff51
|
||||
[test_cmath.py]=1 # FIXME: Works on c90ff51
|
||||
|
||||
[test_atexit.py]=1 # The atexit test starting at 3.3 looks for specific comments in error lines
|
||||
|
||||
[test_cmd_line.py]=1 # too long?
|
||||
[test_concurrent_futures.py]=1 # too long?
|
||||
@@ -30,6 +42,7 @@ SKIP_TESTS=(
|
||||
|
||||
[test_nntplib.py]=1
|
||||
|
||||
[test_pep352.py]=1 # test failures
|
||||
[test_peepholer.py]=1
|
||||
[test_poll.py]=1 # test takes too long to run: 11 seconds
|
||||
[test_pty.py]=1 # FIXME: Needs grammar loop isolation separation
|
||||
@@ -57,7 +70,7 @@ SKIP_TESTS=(
|
||||
)
|
||||
# About 300 unit-test files in about 20 minutes
|
||||
|
||||
if (( batch )) ; then
|
||||
if (( BATCH )) ; then
|
||||
SKIP_TESTS[test_ftplib.py]=1 # Runs too long on POWER; over 15 seconds
|
||||
SKIP_TESTS[test_idle.py]=1 # No tk
|
||||
SKIP_TESTS[test_pep352.py]=1 # UnicodeDecodeError may be funny on weird environments
|
||||
|
@@ -1,11 +1,29 @@
|
||||
SKIP_TESTS=(
|
||||
# FIXME: Did this work sometime in the past ?
|
||||
# for elem in g(s):
|
||||
# if not tgt and isOdd(elem): continue
|
||||
# is erroneously:
|
||||
# for elem in g(s):
|
||||
# if tgt or isOdd(elem):
|
||||
# pass
|
||||
# else:
|
||||
# tgt.append(elem)
|
||||
[test_itertools.py]=1
|
||||
|
||||
[test_buffer.py]=1 # FIXME: Works on c90ff51
|
||||
[test_cmath.py]=1 # FIXME: Works on c90ff51
|
||||
[test_strftime.py]=1 # FIXME: Works on c90ff51
|
||||
|
||||
[test___all__.py]=1 # it fails on its own
|
||||
[test_atexit.py]=1 # The atexit test looks for specific comments in error lines
|
||||
|
||||
[test_cmd_line.py]=1 # takes too long to run
|
||||
[test_concurrent_futures.py]=1 # too long?
|
||||
|
||||
[test_configparser.py]=1 # Doesn't terminate
|
||||
[test_ctypes.py]=1 # it fails on its own
|
||||
[test_curses.py]=1 # Investigate
|
||||
|
||||
[test_dbm_gnu.py]=1 # fails on its own
|
||||
[test_devpoll.py]=1 # it fails on its own
|
||||
[test_descr.py]=1 # test assertion errors
|
||||
@@ -14,33 +32,44 @@ SKIP_TESTS=(
|
||||
[test_doctest2.py]=1
|
||||
[test_doctest.py]=1 # test assert failures
|
||||
[test_docxmlrpc.py]=1
|
||||
|
||||
[test_enum.py]=1 # compile syntax?
|
||||
[test_exceptions.py]=1
|
||||
|
||||
[test_faulthandler.py]=1
|
||||
[test_file_eintr.py]=1 # parse error
|
||||
[test_fork1.py]=1 # too long
|
||||
|
||||
[test_gdb.py]=1 # it fails on its own
|
||||
[test_grammar.py]=1 # parse error
|
||||
|
||||
[test_httplib.py]=1 # it fails on its own
|
||||
|
||||
[test_import.py]=1 # it fails on its own
|
||||
[test_io.py]=1
|
||||
[test_ioctl.py]=1 # it fails on its own
|
||||
[test_inspect.py]=1 # Syntax error Investigate
|
||||
|
||||
[test_logging.py]=1 # Too long to run
|
||||
[test_long.py]=1 # FIXME: Works on c90ff51
|
||||
|
||||
[test_modulefinder.py]=1 # test assertion error
|
||||
[test_multiprocessing_fork.py]=1 # doesn't terminate
|
||||
[test_multiprocessing_forkserver.py]=1 # doesn't terminate
|
||||
[test_multiprocessing_main_handling.py]=1 # doesn't terminate
|
||||
[test_multiprocessing_spawn.py]=1 # doesn't terminate
|
||||
|
||||
[test_nntplib.py]=1 # too long to run
|
||||
|
||||
[test_peepholer.py]=1 # control flow?
|
||||
[test_pep352.py]=1 # test assert failures
|
||||
[test_pickle.py]=1 # test assert failures
|
||||
[test_pkgimport.py]=1 # long
|
||||
[test_poll.py]=1 # Too long to run: 11 seconds
|
||||
[test_pydoc.py]=1 # test assertion failures
|
||||
|
||||
[test_runpy.py]=1 # Too long:
|
||||
|
||||
[test_select.py]=1 # Too long: 11 seconds
|
||||
[test_selectors.py]=1 # Too long: 11 seconds
|
||||
[test_signal.py]=1 # Too long: 22 seconds
|
||||
@@ -50,12 +79,15 @@ SKIP_TESTS=(
|
||||
[test_subprocess.py]=1 # Too long
|
||||
[test_symtable.py]=1 # Investigate bad output
|
||||
[test_sys_settrace.py]=1 # test assert failures
|
||||
|
||||
[test_tcl.py]=1 # May be implementation specific. On POWER though it fails
|
||||
[test_threading.py]=1 # Too long
|
||||
[test_threadsignals.py]=1 # Too long to run: 12 seconds
|
||||
[test_timeout.py]=1 # Too long to run: 19 seconds
|
||||
[test_traceback.py]=1 # introspects on code
|
||||
|
||||
[test_urllib2net.py]=1 # Doesn't terminate
|
||||
|
||||
[test_zipfile64.py]=1
|
||||
[test_zlib.py]=1
|
||||
)
|
||||
@@ -66,5 +98,4 @@ if (( batch )) ; then
|
||||
# Figure out what's up here
|
||||
SKIP_TESTS[test_exception_variations.py]=1
|
||||
SKIP_TESTS[test_mailbox.py]=1 # Takes to long on POWER; over 15 secs
|
||||
SKIP_TESTS[test_quopri.py]=1
|
||||
fi
|
||||
|
@@ -1,11 +1,7 @@
|
||||
SKIP_TESTS=(
|
||||
[test_buffer.py]=1 # FIXME: Works on c90ff51
|
||||
[test_decorators.py]=1 # FIXME: Works on c90ff51
|
||||
[test_platform.py]=1 # FIXME: Works on c90ff51
|
||||
[test_pyclbr.py]=1 # FIXME: Works on c90ff51
|
||||
[test_tempfile.py]=1 # FIXME: Works on c90ff51
|
||||
[test_uu.py]=1 # FIXME: Works on c90ff51
|
||||
[test_ftplib.py]=1 # FIXME: Works on c90ff51
|
||||
[test_platform.py]=1 # FIXME: Works on c90ff51
|
||||
[test_pyclbr.py]=1 # FIXME: Works on c90ff51
|
||||
|
||||
[test___all__.py]=1 # it fails on its own
|
||||
[test_aifc.py]=1 #
|
||||
@@ -100,6 +96,7 @@ SKIP_TESTS=(
|
||||
[test_sys_settrace.py]=1 # test assert fail
|
||||
|
||||
[test_tcl.py]=1 # it fails on its own
|
||||
[test_tempfile.py]=1 # test assertion failures
|
||||
[test_thread.py]=1
|
||||
[test_threading.py]=1
|
||||
[test_timeout.py]=1
|
||||
@@ -115,6 +112,7 @@ SKIP_TESTS=(
|
||||
[test_urllib2net.py]=1 # it fails on its own
|
||||
[test_urllibnet.py]=1 # it fails on its own
|
||||
[test_urlparse.py]=1 # test assert error
|
||||
[test_uu.py]=1 # test assert error
|
||||
|
||||
[test_winreg.py]=1 # it fails on its own
|
||||
[test_winsound.py]=1 # it fails on its own
|
||||
@@ -129,7 +127,7 @@ SKIP_TESTS=(
|
||||
)
|
||||
# About 260 unit-test in about 16 minutes
|
||||
|
||||
if (( batch )) ; then
|
||||
if (( BATCH )) ; then
|
||||
SKIP_TESTS[test_asyncore.py]=1 # Ok, but takes more than 15 seconds to run
|
||||
SKIP_TESTS[test_bisect.py]=1
|
||||
SKIP_TESTS[test_compileall.py]=1 # Something weird on POWER
|
||||
@@ -137,10 +135,10 @@ if (( batch )) ; then
|
||||
SKIP_TESTS[test_distutils.py]=1
|
||||
|
||||
SKIP_TESTS[test_exception_variations.py]=1
|
||||
SKIP_TESTS[test_ioctl.py]=1 # it fails on its own
|
||||
SKIP_TESTS[test_poplib.py]=1 # May be a result of POWER installation
|
||||
|
||||
SKIP_TESTS[test_quopri.py]=1
|
||||
SKIP_TESTS[test_ioctl.py]=1 # it fails on its own
|
||||
SKIP_TESTS[test_sysconfig.py]=1 # POWER extension fails
|
||||
SKIP_TESTS[test_tarfile.py]=1 # too long to run on POWER 15 secs
|
||||
SKIP_TESTS[test_venv.py]=1 # takes too long 11 seconds
|
||||
fi
|
||||
|
@@ -1,13 +1,12 @@
|
||||
SKIP_TESTS=(
|
||||
[test_ast.py]=1 # FIXME: Works on c90ff51
|
||||
[test_binop.py]=1 # FIXME: Works on c90ff51
|
||||
[test_complex.py]=1 # FIXME: Works on c90ff51
|
||||
[test_cmath.py]=1 # FIXME: Works on c90ff51
|
||||
[test_format.py]=1 # FIXME: Works on c90ff51
|
||||
[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_timeit.py]=1 # FIXME: Works on c90ff51
|
||||
[test_os.py]=1 # FIXME: Works on c90ff51
|
||||
[test_os.py]=1 # parse error FIXME: Works on c90ff51
|
||||
|
||||
[test___all__.py]=1 # it fails on its own
|
||||
[test_aifc.py]=1 #
|
||||
@@ -49,6 +48,7 @@ SKIP_TESTS=(
|
||||
[test_datetime.py]=1 # it fails on its own
|
||||
[test_dbm_ndbm.py]=1 # it fails on its own
|
||||
[test_decimal.py]=1
|
||||
[test_decorators.py]=1 # control-flow failures
|
||||
[test_descr.py]=1 # syntax error: Investigate
|
||||
[test_devpoll.py]=1 # it fails on its own
|
||||
[test_dict.py]=1 # it fails on its own
|
||||
@@ -106,7 +106,8 @@ SKIP_TESTS=(
|
||||
[test_nntplib.py]=1 # test takes too long to run: 31 seconds
|
||||
[test_normalization.py]=1 # it fails on its own
|
||||
|
||||
[test_ordered_dict.py]= # it fails on its own
|
||||
[test_optparse.py]=1 # test fails
|
||||
[test_ordered_dict.py]=1 # it fails on its own
|
||||
[test_ossaudiodev.py]=1 # it fails on its own
|
||||
|
||||
[test_pdb.py]=1 # Probably introspection
|
||||
@@ -122,8 +123,6 @@ SKIP_TESTS=(
|
||||
[test_pyclbr.py]=1 # it fails on its own
|
||||
[test_pydoc.py]=1 # it fails on its own
|
||||
|
||||
[test_quopri.py]=1 # AssertionError: b'123=four' != '123=four'
|
||||
|
||||
[test_random.py]=1 # it fails on its own
|
||||
[test_range.py]=1
|
||||
[test_regrtest.py]=1 # test takes too long to run: 12 seconds
|
||||
@@ -147,6 +146,7 @@ SKIP_TESTS=(
|
||||
[test_startfile.py]=1 # it fails on its own
|
||||
[test_statistics.py]=1 # it fails on its own
|
||||
[test_string_literals.py]=1
|
||||
[test_strftime.py]=1 # test assertion failures
|
||||
[test_strtod.py]=1 # it fails on its own
|
||||
[test_struct.py]=1 # test assertion errors
|
||||
[test_subprocess.py]=1
|
||||
@@ -200,8 +200,10 @@ SKIP_TESTS=(
|
||||
)
|
||||
# 236 unit-test files in about 13 minutes
|
||||
|
||||
if (( batch )) ; then
|
||||
if (( BATCH )) ; then
|
||||
SKIP_TESTS[test_codeccallbacks.py]=1
|
||||
SKIP_TESTS[test_complex.py]=1 # Something funky with POWER8
|
||||
|
||||
# locale on test machine is probably customized
|
||||
SKIP_TESTS[test__locale.py]=1
|
||||
fi
|
||||
|
@@ -1,6 +1,22 @@
|
||||
SKIP_TESTS=(
|
||||
# FIXME: Did this work sometime in the past ?
|
||||
# for elem in g(s):
|
||||
# if not tgt and isOdd(elem): continue
|
||||
# is erroneously:
|
||||
# for elem in g(s):
|
||||
# if tgt or isOdd(elem):
|
||||
# pass
|
||||
# else:
|
||||
# tgt.append(elem)
|
||||
[test_itertools.py]=1
|
||||
|
||||
# Fails on decompyle3 as well.
|
||||
# complicated control flow and "and/or" expressions
|
||||
[test_pickle.py]=1
|
||||
|
||||
[test_builtin.py]=1 # FIXME works on decompyle6
|
||||
[test_context.py]=1 # FIXME works on decompyle6
|
||||
[test_doctest2.py]=1 # FIXME works on decompyle6
|
||||
[test_format.py]=1 # FIXME works on decompyle6
|
||||
[test_marshal.py]=1 # FIXME works on decompyle6
|
||||
[test_normalization.py]=1 # FIXME works on decompyle6
|
||||
@@ -9,12 +25,11 @@ SKIP_TESTS=(
|
||||
[test_slice.py]=1 # FIXME works on decompyle6
|
||||
[test_sort.py]=1 # FIXME works on decompyle6
|
||||
[test_statistics.py]=1 # FIXME works on decompyle6
|
||||
[test_string_literals.py]=1 # FIXME works on decompyle6
|
||||
[test_timeit.py]=1 # FIXME works on decompyle6
|
||||
[test_urllib2_localnet.py]=1 # FIXME works on decompyle6
|
||||
[test_urllib2.py]=1 # FIXME: works on uncompyle6
|
||||
[test_generators.py]=1 # Investigate improper lamdba with bogus "False" added
|
||||
[test_grammar.py]=1 # investigate: like above: semantic rule missing probably
|
||||
[test_generators.py]=1 # FIXME: works on uncompyle6 - lambda parsing probably
|
||||
[test_grammar.py]=1 # FIXME: works on uncompyle6 - lambda parsing probably
|
||||
|
||||
[test___all__.py]=1 # it fails on its own
|
||||
[test_argparse.py]=1 #- it fails on its own
|
||||
@@ -48,6 +63,7 @@ SKIP_TESTS=(
|
||||
|
||||
[test_faulthandler.py]=1 # test takes too long before decompiling
|
||||
[test_fileinput.py]=1 # Test assertion failures
|
||||
[test_finalization.py]=1 # if/else logic
|
||||
[test_frame.py]=1 # test assertion errors
|
||||
[test_ftplib.py]=1 # parse error
|
||||
[test_fstring.py]=1 # need to disambiguate leading fstrings from docstrings
|
||||
@@ -133,7 +149,8 @@ SKIP_TESTS=(
|
||||
)
|
||||
# 306 unit-test files in about 19 minutes
|
||||
|
||||
if (( batch )) ; then
|
||||
if (( BATCH )) ; then
|
||||
SKIP_TESTS[test_capi.py]=1 # more than 15 secs to run on POWER
|
||||
SKIP_TESTS[test_dbm_gnu.py]=1 # fails on its own on POWER
|
||||
SKIP_TESTS[test_distutils.py]=1
|
||||
SKIP_TESTS[test_fileio.py]=1
|
||||
|
@@ -1,10 +1,45 @@
|
||||
SKIP_TESTS=(
|
||||
[test_time.py]=1 # FIXME: works on uncompyle6?
|
||||
[test_mimetypes.py]=1 # parse error. decompile3 works. Release 3.6.4 works?
|
||||
[test_time.py]=1 # FIXME: parse eror. decompyle3 works. Release 3.6.4 works?
|
||||
[test_aifc.py]=1 # parse error; decompile3 works
|
||||
|
||||
[test_doctest2.py]=1 # test failures release 3.6.4 works?
|
||||
[test_finalization.py]=1 # test failures release 3.6.4 works?
|
||||
[test_urllib2.py]=1 # FIXME: works on uncompyle6?
|
||||
[test_zipimport.py]=1 # FIXME: works on uncompyle6
|
||||
|
||||
# From decompyle3 excludes
|
||||
# Very Simple example. Compare with 3.7 Need 3.8 parse rules for exception handling return
|
||||
# for proto in p:
|
||||
# try:
|
||||
# drop = 5
|
||||
# except StopIteration:
|
||||
# continue
|
||||
|
||||
[test_dict.py]=1 #
|
||||
|
||||
# Simple example. Compare with 3.7 Need 3.8 parse rules for exception handling return
|
||||
# try:
|
||||
# return 5
|
||||
# except KeyError:
|
||||
# return res
|
||||
# except TypeError:
|
||||
# return 10
|
||||
|
||||
# These and the above may be due to new code generation or tests
|
||||
# between 3.8.3 and 3.8.5 ?
|
||||
[test_decorators.py]=1 #
|
||||
|
||||
[test_dtrace.py]=1 #
|
||||
[test_exceptions.py]=1 #
|
||||
[test_ftplib.py]=1 #
|
||||
[test_gc.py]=1 #
|
||||
[test_gzip.py]=1 #
|
||||
[test_hashlib.py]=1 #
|
||||
[test_iter.py]=1 #
|
||||
[test_itertools.py]=1 #
|
||||
|
||||
[test___all__.py]=1 # it fails on its own
|
||||
[test_aifc.py]=1 # parse error
|
||||
[test_argparse.py]=1 #- it fails on its own
|
||||
[test_array.py]=1 #- parse error
|
||||
[test_asdl_parser.py]=1 # it fails on its own
|
||||
@@ -76,6 +111,7 @@ SKIP_TESTS=(
|
||||
[test_difflib.py]=1 # parse error
|
||||
[test_dis.py]=1 # We change line numbers - duh!
|
||||
[test_doctest.py]=1 # parse error
|
||||
[test_doctest2.py]=1 # test faiures relesae 3.6.4 works?
|
||||
[test_docxmlrpc.py]=1
|
||||
[test_dtrace.py]=1 # parse error
|
||||
[test_dummy_thread.py]=1 # parse error
|
||||
@@ -91,6 +127,7 @@ SKIP_TESTS=(
|
||||
[test_exceptions.py]=1 # parse error
|
||||
|
||||
[test_faulthandler.py]=1 # takes too long
|
||||
[test_file_eintr.py]=1 # too long to run test; works on 3.7.7
|
||||
[test_fcntl.py]=1
|
||||
[test_filecmp.py]=1 # parse error
|
||||
[test_fileinput.py]=1
|
||||
@@ -329,7 +366,7 @@ SKIP_TESTS=(
|
||||
)
|
||||
# 114 test files, Elapsed time about 7 minutes
|
||||
|
||||
if (( batch )) ; then
|
||||
if (( BATCH )) ; then
|
||||
SKIP_TESTS[test_idle.py]=1 # Probably installation specific
|
||||
SKIP_TESTS[test_tix.py]=1 # fails on its own
|
||||
SKIP_TESTS[test_ttk_textonly.py]=1 # Installation dependent?
|
||||
|
@@ -3,55 +3,90 @@
|
||||
function displaytime {
|
||||
printf "ran in "
|
||||
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 '
|
||||
((D=T/60/60/24))
|
||||
((H=T/60/60%24))
|
||||
((M=T/60%60))
|
||||
((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
|
||||
}
|
||||
|
||||
. ../../admin-tools/pyenv-newer-versions
|
||||
bs=${BASH_SOURCE[0]}
|
||||
if [[ $0 != $bs ]] ; then
|
||||
echo "This script should not be *sourced* but run through bash"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mydir=$(dirname $bs)
|
||||
cd $mydir
|
||||
|
||||
branch=$(cat ../../.git/HEAD | cut -d'/' -f 3)
|
||||
if [[ $branch == 'python-2.4' ]]; then
|
||||
. ../../admin-tools/pyenv-older-versions
|
||||
elif [[ $branch == 'master' ]]; then
|
||||
. ../../admin-tools/pyenv-newer-versions
|
||||
else
|
||||
echo &1>2 "Error git branch should either be 'master' or 'python-2.4'; got: '$branch'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MAIN="runtests.sh"
|
||||
|
||||
|
||||
USER=${USER:-rocky}
|
||||
EMAIL=${EMAIL:-rb@dustyfeet.com}
|
||||
SUBJECT_PREFIX="stdlib unit testing for"
|
||||
WHAT="uncompyle6 ${MAIN}"
|
||||
export BATCH=1
|
||||
|
||||
typeset -i RUN_STARTTIME=$(date +%s)
|
||||
|
||||
actual_versions=""
|
||||
DEBUG="" # -x
|
||||
|
||||
MAILBODY=/tmp/${MAIN}-mailbody-$$.txt
|
||||
|
||||
for VERSION in $PYVERSIONS ; do
|
||||
typeset -i rc=0
|
||||
LOGFILE=/tmp/runtests-$VERSION-$$.log
|
||||
|
||||
case "$VERSION" in
|
||||
3.0.1 | 3.1.5 | 3.2.6 | 3.8.1 )
|
||||
3.0.1 | 3.1.5 | 3.2.6 | 3.8.5 )
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
actual_versions="$actual_versions $VERSION"
|
||||
|
||||
if ! pyenv local $VERSION ; then
|
||||
rc=1
|
||||
else
|
||||
STOP_ONERROR=1 /bin/bash $DEBUG ./runtests.sh >$LOGFILE 2>&1
|
||||
rc=$?
|
||||
typeset -i ALL_FILES_STARTTIME=$(date +%s)
|
||||
STOP_ONERROR=1 /bin/bash $DEBUG ./runtests.sh >$LOGFILE 2>&1
|
||||
rc=$?
|
||||
|
||||
echo Python Version $(pyenv local) >> $LOGFILE
|
||||
echo "" >>$LOGFILE
|
||||
typeset -i ALL_FILES_ENDTIME=$(date +%s)
|
||||
(( time_diff = ALL_FILES_ENDTIME - ALL_FILES_STARTTIME))
|
||||
time_str=$(displaytime $time_diff)
|
||||
echo ${time_str}. >> $LOGFILE
|
||||
fi
|
||||
SUBJECT_PREFIX="runtests verify for"
|
||||
|
||||
SUBJECT_PREFIX="$WHAT for"
|
||||
if ((rc == 0)); then
|
||||
mailbody_line="Python $VERSION ok; ${time_str}."
|
||||
tail -v $LOGFILE | mail -s "$SUBJECT_PREFIX $VERSION ok" ${USER}@localhost
|
||||
else
|
||||
mailbody_line="Python $VERSION failed; ${time_str}."
|
||||
tail -v $LOGFILE | mail -s "$SUBJECT_PREFIX $VERSION not ok" ${USER}@localhost
|
||||
tail -v $LOGFILE | mail -s "$SUBJECT_PREFIX $VERSION not ok" $EMAIL
|
||||
tail -v $LOGFILE | mail -s "$HOST $SUBJECT_PREFIX $VERSION not ok" $EMAIL
|
||||
fi
|
||||
echo $mailbody_line >> $MAILBODY
|
||||
done
|
||||
|
||||
typeset -i RUN_ENDTIME=$(date +%s)
|
||||
(( time_diff = RUN_ENDTIME - RUN_STARTTIME))
|
||||
elapsed_time=$(displaytime $time_diff)
|
||||
echo "Run complete $elapsed_time for versions $actual_versions" | mail -s "runtests in $elapsed_time" ${EMAIL}
|
||||
echo "${WHAT} complete; ${elapsed_time}." >> $MAILBODY
|
||||
echo "Full results are in ${LOGFILE}." >> $MAILBODY
|
||||
cat $MAILBODY | mail -s "$HOST $WHAT $elapsed_time" ${EMAIL}
|
||||
|
@@ -1,10 +1,12 @@
|
||||
#!/bin/bash
|
||||
me=${BASH_SOURCE[0]}
|
||||
|
||||
typeset -i batch=1
|
||||
isatty=$(/usr/bin/tty 2>/dev/null)
|
||||
if [[ -n $isatty ]] && [[ "$isatty" != 'not a tty' ]] ; then
|
||||
batch=0
|
||||
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
|
||||
|
||||
|
||||
@@ -72,11 +74,10 @@ case $PYVERSION in
|
||||
[test_dis.py]=1 # We change line numbers - duh!
|
||||
[test_fileio.py]=1
|
||||
)
|
||||
if (( batch )) ; then
|
||||
if (( BATCH )) ; then
|
||||
# Fails in crontab environment?
|
||||
# Figure out what's up here
|
||||
SKIP_TESTS[test_exception_variations.py]=1
|
||||
SKIP_TESTS[test_quopri.py]=1
|
||||
fi
|
||||
;;
|
||||
3.1)
|
||||
@@ -85,11 +86,10 @@ case $PYVERSION in
|
||||
[test_dis.py]=1 # We change line numbers - duh!
|
||||
[test_fileio.py]=1
|
||||
)
|
||||
if (( batch )) ; then
|
||||
if (( BATCH )) ; then
|
||||
# Fails in crontab environment?
|
||||
# Figure out what's up here
|
||||
SKIP_TESTS[test_exception_variations.py]=1
|
||||
SKIP_TESTS[test_quopri.py]=1
|
||||
fi
|
||||
;;
|
||||
3.2)
|
||||
@@ -129,6 +129,7 @@ fulldir=$(pwd)
|
||||
|
||||
# DECOMPILER=uncompyle2
|
||||
DECOMPILER=${DECOMPILER:-"$fulldir/../../bin/uncompyle6"}
|
||||
OPTS=${OPTS:-""}
|
||||
TESTDIR=/tmp/test${PYVERSION}
|
||||
if [[ -e $TESTDIR ]] ; then
|
||||
rm -fr $TESTDIR
|
||||
@@ -137,6 +138,8 @@ fi
|
||||
PYENV_ROOT=${PYENV_ROOT:-$HOME/.pyenv}
|
||||
pyenv_local=$(pyenv local)
|
||||
|
||||
echo Python version is $pyenv_local
|
||||
|
||||
# pyenv version update
|
||||
for dir in ../ ../../ ; do
|
||||
cp -v .python-version $dir
|
||||
@@ -145,18 +148,25 @@ done
|
||||
|
||||
mkdir $TESTDIR || exit $?
|
||||
cp -r ${PYENV_ROOT}/versions/${PYVERSION}.${MINOR}/lib/python${PYVERSION}/test $TESTDIR
|
||||
cd $TESTDIR/test
|
||||
if [[ $PYVERSION == 3.2 ]] ; then
|
||||
cp ${PYENV_ROOT}/versions/${PYVERSION}.${MINOR}/lib/python${PYVERSION}/test/* $TESTDIR
|
||||
cd $TESTDIR
|
||||
else
|
||||
cd $TESTDIR/test
|
||||
fi
|
||||
pyenv local $FULLVERSION
|
||||
export PYTHONPATH=$TESTDIR
|
||||
export PATH=${PYENV_ROOT}/shims:${PATH}
|
||||
|
||||
DONT_SKIP_TESTS=${DONT_SKIP_TESTS:-0}
|
||||
|
||||
# Run tests
|
||||
typeset -i i=0
|
||||
typeset -i allerrs=0
|
||||
if [[ -n $1 ]] ; then
|
||||
files=$1
|
||||
typeset -a files_ary=( $(echo $1) )
|
||||
if (( ${#files_ary[@]} == 1 )) ; then
|
||||
files=$@
|
||||
typeset -a files_ary=( $(echo $@) )
|
||||
if (( ${#files_ary[@]} == 1 || DONT_SKIP_TESTS == 1 )) ; then
|
||||
SKIP_TESTS=()
|
||||
fi
|
||||
else
|
||||
@@ -166,9 +176,12 @@ fi
|
||||
typeset -i ALL_FILES_STARTTIME=$(date +%s)
|
||||
typeset -i skipped=0
|
||||
|
||||
NOT_INVERTED_TESTS=${NOT_INVERTED_TESTS:-1}
|
||||
|
||||
for file in $files; do
|
||||
# AIX bash doesn't grok [[ -v SKIP... ]]
|
||||
if [[ ${SKIP_TESTS[$file]} == 1 ]] ; then
|
||||
[[ -z ${SKIP_TESTS[$file]} ]] && SKIP_TESTS[$file]=0
|
||||
if [[ ${SKIP_TESTS[$file]} == ${NOT_INVERTED_TESTS} ]] ; then
|
||||
((skipped++))
|
||||
continue
|
||||
fi
|
||||
@@ -185,7 +198,7 @@ for file in $files; do
|
||||
typeset -i ENDTIME=$(date +%s)
|
||||
typeset -i time_diff
|
||||
(( time_diff = ENDTIME - STARTTIME))
|
||||
if (( time_diff > 10 )) ; then
|
||||
if (( time_diff > $timeout )) ; then
|
||||
echo "Skipping test $file -- test takes too long to run: $time_diff seconds"
|
||||
continue
|
||||
fi
|
||||
@@ -197,7 +210,7 @@ for file in $files; do
|
||||
$fulldir/compile-file.py $file && \
|
||||
mv $file{,.orig} && \
|
||||
echo ========== $(date +%X) Decompiling $file ===========
|
||||
$DECOMPILER $decompiled_file > $file
|
||||
$DECOMPILER $OPTS $decompiled_file > $file
|
||||
rc=$?
|
||||
if (( rc == 0 )) ; then
|
||||
echo ========== $(date +%X) Running $file ===========
|
||||
|
2
tox.ini
2
tox.ini
@@ -3,7 +3,7 @@
|
||||
[flake8]
|
||||
exclude = .tox,./build,./trepan/processor/command/tmp
|
||||
filename = *.py
|
||||
ignore = C901,E113,E121,E122,E123,E124,E125,E126,E127,E128,E129,E201,E202,E203,E221,E222,E225,E226,E241,E242,E251,E261,E271,E272,E302,E401,E402,E501,F401,E701,E702
|
||||
ignore = C901,E113,E121,E122,E123,E124,E125,E126,E127,E128,E129,E201,E202,E203,E221,E222,E225,E226,E241,E242,E251,E261,E271,E272,E302,E401,E402,E501,F401,E701,E702,W503
|
||||
|
||||
[tox]
|
||||
envlist = py27, py34, pypy
|
||||
|
@@ -1,7 +0,0 @@
|
||||
# Whatever it is you want to do, it should be forwarded to the
|
||||
# to top-level irectories
|
||||
PHONY=check all
|
||||
all: check
|
||||
|
||||
%:
|
||||
$(MAKE) -C .. $@
|
@@ -28,20 +28,25 @@
|
||||
|
||||
import sys
|
||||
|
||||
__docformat__ = 'restructuredtext'
|
||||
__docformat__ = "restructuredtext"
|
||||
|
||||
PYTHON3 = (sys.version_info >= (3, 0))
|
||||
from uncompyle6.version import VERSION
|
||||
|
||||
# This ensures VERSION will appear in pydoc
|
||||
__version__ = VERSION
|
||||
|
||||
PYTHON3 = sys.version_info >= (3, 0)
|
||||
|
||||
# We do this crazy way to support Python 2.6 which
|
||||
# doesn't support version_major, and has a bug in
|
||||
# floating point so we can't divide 26 by 10 and get
|
||||
# 2.6
|
||||
PYTHON_VERSION = sys.version_info[0] + (sys.version_info[1] / 10.0)
|
||||
PYTHON_VERSION_STR = "%s.%s" % (sys.version_info[0], sys.version_info[1])
|
||||
PYTHON_VERSION_STR = "%s.%s" % (sys.version_info[0], sys.version_info[1])
|
||||
|
||||
IS_PYPY = '__pypy__' in sys.builtin_module_names
|
||||
IS_PYPY = "__pypy__" in sys.builtin_module_names
|
||||
|
||||
if hasattr(sys, 'setrecursionlimit'):
|
||||
if hasattr(sys, "setrecursionlimit"):
|
||||
# pyston doesn't have setrecursionlimit
|
||||
sys.setrecursionlimit(5000)
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2015-2016, 2818-2019 by Rocky Bernstein
|
||||
# Copyright (c) 2015-2016, 2818-2020 by Rocky Bernstein
|
||||
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
|
||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||
# Copyright (c) 1999 John Aycock
|
||||
@@ -34,8 +34,7 @@ from __future__ import print_function
|
||||
import sys
|
||||
from collections import deque
|
||||
|
||||
from xdis.code import iscode
|
||||
from xdis.load import check_object_path, load_module
|
||||
from xdis import check_object_path, iscode, load_module
|
||||
from uncompyle6.scanner import get_scanner
|
||||
|
||||
|
||||
@@ -100,7 +99,9 @@ def disassemble_file(filename, outstream=None):
|
||||
try to find the corresponding compiled object.
|
||||
"""
|
||||
filename = check_object_path(filename)
|
||||
(version, timestamp, magic_int, co, is_pypy, source_size) = load_module(filename)
|
||||
(version, timestamp, magic_int, co, is_pypy, source_size, sip_hash) = load_module(
|
||||
filename
|
||||
)
|
||||
if type(co) == list:
|
||||
for con in co:
|
||||
disco(version, con, outstream)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2015-2016, 2818 by Rocky Bernstein
|
||||
# Copyright (c) 2015-2016, 2818, 2020 by Rocky Bernstein
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -15,14 +15,27 @@
|
||||
|
||||
from collections import deque
|
||||
|
||||
from xdis.code import iscode
|
||||
from xdis.load import load_file, load_module
|
||||
from xdis.main import get_opcode
|
||||
from xdis.bytecode import Bytecode, findlinestarts, offset2line
|
||||
from xdis import (
|
||||
Bytecode,
|
||||
iscode,
|
||||
findlinestarts,
|
||||
get_opcode,
|
||||
offset2line,
|
||||
load_file,
|
||||
load_module,
|
||||
)
|
||||
|
||||
|
||||
def line_number_mapping(pyc_filename, src_filename):
|
||||
(version, timestamp, magic_int, code1, is_pypy,
|
||||
source_size) = load_module(pyc_filename)
|
||||
(
|
||||
version,
|
||||
timestamp,
|
||||
magic_int,
|
||||
code1,
|
||||
is_pypy,
|
||||
source_size,
|
||||
sip_hash,
|
||||
) = load_module(pyc_filename)
|
||||
try:
|
||||
code2 = load_file(src_filename)
|
||||
except SyntaxError as e:
|
||||
@@ -44,7 +57,10 @@ def number_loop(queue, mappings, opc):
|
||||
assert code1.co_name == code2.co_name
|
||||
linestarts_orig = findlinestarts(code1)
|
||||
linestarts_uncompiled = list(findlinestarts(code2))
|
||||
mappings += [[line, offset2line(offset, linestarts_uncompiled)] for offset, line in linestarts_orig]
|
||||
mappings += [
|
||||
[line, offset2line(offset, linestarts_uncompiled)]
|
||||
for offset, line in linestarts_orig
|
||||
]
|
||||
bytecode1 = Bytecode(code1, opc)
|
||||
bytecode2 = Bytecode(code2, opc)
|
||||
instr2s = bytecode2.get_instructions(code2)
|
||||
|
@@ -16,8 +16,7 @@ from __future__ import print_function
|
||||
import datetime, py_compile, os, subprocess, sys, tempfile
|
||||
|
||||
from uncompyle6 import verify, IS_PYPY, PYTHON_VERSION
|
||||
from xdis.code import iscode
|
||||
from xdis.magics import sysinfo2float
|
||||
from xdis import iscode, sysinfo2float
|
||||
from uncompyle6.disas import check_object_path
|
||||
from uncompyle6.semantics import pysource
|
||||
from uncompyle6.parser import ParserError
|
||||
@@ -102,7 +101,7 @@ def decompile(
|
||||
)
|
||||
if PYTHON_VERSION < 3.0 and bytecode_version >= 3.0:
|
||||
write(
|
||||
"# Warning: this version has problems handling the Python 3 byte type in contants properly.\n"
|
||||
'# Warning: this version of Python has problems handling the Python 3 "byte" type in constants properly.\n'
|
||||
)
|
||||
|
||||
if co.co_filename:
|
||||
@@ -120,12 +119,10 @@ def decompile(
|
||||
mapstream = _get_outstream(mapstream)
|
||||
|
||||
deparsed = deparse_code_with_map(
|
||||
bytecode_version,
|
||||
co,
|
||||
out,
|
||||
showasm,
|
||||
showast,
|
||||
showgrammar,
|
||||
bytecode_version,
|
||||
debug_opts,
|
||||
code_objects=code_objects,
|
||||
is_pypy=is_pypy,
|
||||
)
|
||||
@@ -183,7 +180,7 @@ def decompile_file(
|
||||
|
||||
filename = check_object_path(filename)
|
||||
code_objects = {}
|
||||
(version, timestamp, magic_int, co, is_pypy, source_size) = load_module(
|
||||
(version, timestamp, magic_int, co, is_pypy, source_size, sip_hash) = load_module(
|
||||
filename, code_objects
|
||||
)
|
||||
|
||||
|
@@ -23,16 +23,16 @@ from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
||||
from xdis.code import iscode
|
||||
from xdis.magics import py_str2float
|
||||
from xdis import iscode, py_str2float
|
||||
from spark_parser import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||
from uncompyle6.show import maybe_show_asm
|
||||
|
||||
|
||||
class ParserError(Exception):
|
||||
def __init__(self, token, offset):
|
||||
def __init__(self, token, offset, debug=PARSER_DEFAULT_DEBUG):
|
||||
self.token = token
|
||||
self.offset = offset
|
||||
self.debug = debug
|
||||
|
||||
def __str__(self):
|
||||
return "Parse error at or near `%r' instruction at offset %s\n" % (
|
||||
@@ -206,9 +206,9 @@ class PythonParser(GenericASTBuilder):
|
||||
else:
|
||||
indent = "-> "
|
||||
print("%s%s" % (indent, instructions[i]))
|
||||
raise ParserError(err_token, err_token.offset)
|
||||
raise ParserError(err_token, err_token.offset, self.debug["reduce"])
|
||||
else:
|
||||
raise ParserError(None, -1)
|
||||
raise ParserError(None, -1, self.debug["reduce"])
|
||||
|
||||
def get_pos_kw(self, token):
|
||||
"""Return then the number of positional parameters and
|
||||
@@ -351,13 +351,13 @@ class PythonParser(GenericASTBuilder):
|
||||
stmt ::= try_except
|
||||
stmt ::= tryelsestmt
|
||||
stmt ::= tryfinallystmt
|
||||
stmt ::= withstmt
|
||||
stmt ::= with
|
||||
stmt ::= withasstmt
|
||||
|
||||
stmt ::= del_stmt
|
||||
del_stmt ::= DELETE_FAST
|
||||
del_stmt ::= DELETE_NAME
|
||||
del_stmt ::= DELETE_GLOBAL
|
||||
stmt ::= delete
|
||||
delete ::= DELETE_FAST
|
||||
delete ::= DELETE_NAME
|
||||
delete ::= DELETE_GLOBAL
|
||||
|
||||
|
||||
stmt ::= return
|
||||
@@ -623,7 +623,7 @@ class PythonParser(GenericASTBuilder):
|
||||
"""
|
||||
|
||||
|
||||
def parse(p, tokens, customize):
|
||||
def parse(p, tokens, customize, code):
|
||||
p.customize_grammar_rules(tokens, customize)
|
||||
ast = p.parse(tokens)
|
||||
# p.cleanup()
|
||||
@@ -878,7 +878,7 @@ def python_parser(
|
||||
# parser_debug = {'rules': True, 'transition': True, 'reduce' : True,
|
||||
# 'showstack': 'full'}
|
||||
p = get_python_parser(version, parser_debug)
|
||||
return parse(p, tokens, customize)
|
||||
return parse(p, tokens, customize, co)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@@ -7,7 +7,7 @@ from uncompyle6.parsers.parse11 import Python11Parser
|
||||
|
||||
class Python10Parser(Python11Parser):
|
||||
def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
|
||||
super(Python11Parser, self).__init__(debug_parser)
|
||||
super(Python10Parser, self).__init__(debug_parser)
|
||||
self.customized = {}
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user