Compare commits

..

359 Commits

Author SHA1 Message Date
rocky
74c7870537 Merge branch 'python-3.6-to-3.10' into python-3.3-to-3.5 2024-12-21 02:34:01 -05:00
rocky
8d07aa0435 Merge branch 'master' into python-3.6-to-3.10 2024-12-21 02:32:06 -05:00
rocky
521c983b51 Administrivia 2024-12-21 02:31:09 -05:00
rocky
4703052817 Merge branch 'python-3.6-to-3.10' into python-3.3-to-3.5 2024-12-12 18:06:33 -05:00
rocky
2f1ab4f63e Merge hell 2024-12-12 18:05:29 -05:00
rocky
5be6946fbf Merge branch 'master' into python-3.6-to-3.10 2024-12-12 18:05:09 -05:00
rocky
7ca4363602 Administrivia 2024-12-12 18:03:31 -05:00
rocky
b2cf041ec3 Remove unused import 2024-12-02 19:39:56 -05:00
R. Bernstein
5e6fad210f Merge pull request #507 from c10udlnk/master
Fix when parsing NOP
2024-12-01 15:13:25 -05:00
c10udlnk
efd28710ce Add NOP test cases
Add test cases for check NOP opcode
2024-12-01 16:22:54 +08:00
c10udlnk
f72b2c1153 Fix when parsing NOP
Fix error when parsing NOP opcode
2024-11-29 11:03:13 +08:00
rocky
e4e3743de5 Tweak when we delete LOAD_CONST RETURN_VALUE 2024-11-28 08:03:32 -05:00
rocky
b71cd88b73 Show return value when not None...
And fixup setup.py
2024-11-28 08:01:15 -05:00
rocky
98a93ae6b9 Merge branch 'master' into python-3.3-to-3.5 2024-11-28 07:30:16 -05:00
rocky
74b39e2262 Administriva 2024-11-28 07:29:37 -05:00
rocky
bb5604aaf1 Merge branch 'master' into python-3.3-to-3.5 2024-11-28 07:28:40 -05:00
rocky
4ac5564df3 Don't remove LOAD_CONST RETURN_VALUE when...
the LOAD_CONST has a non-None value, or the LOAD_CONST
has a line associated with it.
2024-11-28 07:27:13 -05:00
rocky
6171165e90 Merge branch 'master' into python-3.3-to-3.5 2024-11-26 09:45:42 -05:00
rocky
addddf82f5 Correct getting code node on mkfunc 2024-11-26 09:44:49 -05:00
rocky
4181bcbc79 Correct getting code node on mkfunc 2024-11-26 09:43:32 -05:00
rocky
f4d21d36e5 Add BlackHat Asia 2024 and update CircleCI link 2024-11-19 15:33:20 -05:00
rocky
8c15ce92f9 Merge branch 'master' into python-3.3-to-3.5 2024-11-19 15:29:40 -05:00
rocky
f9d32f19d4 Add BlackHat Asia 2024 and update CircleCI link 2024-11-19 15:27:50 -05:00
rocky
9f915384ce Bump spark_parser version allowed 2024-11-15 19:45:29 -05:00
R. Bernstein
2786cbcb89 Merge pull request #504 from rocky/TABLE_DIRECT-pollution
Don't update global tables, copy them instead.
2024-11-12 16:38:40 -05:00
rocky
5c391f9101 Update CircleCI 2024-11-12 16:35:36 -05:00
R. Bernstein
f4becb42e4 Merge pull request #505 from gdesmar/use_single_table_copy
Use a single TABLE copy
2024-11-12 16:17:59 -05:00
gdesmar
cf34014766 Use a single TABLE copy 2024-11-12 19:42:17 +00:00
rocky
37f38e45e1 Don't update global tables...
Work off of copies of them instead. Issue #503
2024-11-09 11:57:11 -05:00
rocky
c65fa2defd Merge branch 'master' into python-3.3-to-3.5 2024-11-09 06:38:25 -05:00
rocky
ab7980374d Allow for newer spark-parser 2024-11-09 06:37:59 -05:00
rocky
7fd642c70e bytes/string tolerance for 3.3 2024-11-09 06:28:41 -05:00
rocky
454f176d6a Merge branch 'master' into python-3.3-to-3.5 2024-11-09 06:13:27 -05:00
rocky
bca623c53c Allow for newer spark-parser 2024-11-09 06:10:10 -05:00
rocky
6e95881fbb Merge branch 'master' into python-3.3-to-3.5 2024-11-09 06:02:50 -05:00
rocky
9b38760173 Administrivia 2024-11-09 06:02:33 -05:00
rocky
61d8dd3e1f Address package version woes 2024-11-09 05:40:46 -05:00
R. Bernstein
27c869b69a Merge pull request #502 from gdesmar/docstring_bytes
Fix for print_docstring()'s `docstring.find(quote)` Type error
2024-10-16 20:31:12 -04:00
gdesmar
7db6a272af Adding tests for bytestring docstring 2024-10-16 20:19:39 +00:00
rocky
36f455011d Merge branch 'python-3.6-to-3.10' into python-3.3-to-3.5 2024-10-10 17:22:44 -04:00
rocky
7b155c4219 Admninistrivia 2024-10-10 17:21:29 -04:00
gdesmar
20d0a60550 Remove duplicate code of print_docstring 2024-10-10 20:24:56 +00:00
rocky
ea3873dba3 Merge branch 'master' into python-3.3-to-3.5 2024-10-09 04:01:29 -04:00
rocky
193c262ffb Administrivia
Folloow branching of other projects in this ilk
2024-10-09 04:00:14 -04:00
rocky
7d017cae08 Administrivia 2024-10-08 19:23:56 -04:00
rocky
f0e1a7beba Try unpinning setuptools 2024-10-08 17:09:07 -04:00
rocky
9ade8e9806 Merge hell 2024-10-08 16:49:03 -04:00
rocky
eb088a84c8 Accept newer python-spark 2024-10-08 16:46:42 -04:00
gdesmar
4cd10b79e2 Convert docstring from bytes to str 2024-10-08 13:48:39 +00:00
rocky
f603a44cf7 Allow newer spark-parser 2024-10-07 11:09:46 -04:00
rocky
80d58f882a Track branch changes in python-spark 2024-10-04 04:46:26 -04:00
rocky
a4818f95bc Merge branch 'master' into python-3.3-to-3.5 2024-09-21 07:31:02 -04:00
rocky
710167b806 Adminsitrivia 2024-09-21 07:29:12 -04:00
rocky
ff192ea6c1 Administrivia 2024-09-21 07:25:44 -04:00
rocky
c309730748 Note version of setuptools working on Python 3.6 2024-09-20 16:23:18 -04:00
rocky
e6c63e419e Administrivia 2024-09-20 16:17:07 -04:00
rocky
a878a74a12 Fixes #501 2024-08-27 11:21:56 -04:00
rocky
3491fcc7d3 Administrivia 2024-08-18 12:49:33 -04:00
rocky
07c0d3f1b2 Merge branch 'master' into python-3.3-to-3.5 2024-07-22 18:33:15 -04:00
rocky
f82caba70f Administrivia 2024-07-22 18:31:59 -04:00
rocky
ddcf4bb5dd Merge branch 'master' into python-3.3-to-3.5 2024-07-22 18:03:44 -04:00
rocky
9f756f74e6 Administrivia 2024-07-22 18:03:17 -04:00
rocky
fcc4535b93 Merge branch 'master' into python-3.3-to-3.5 2024-07-22 17:58:02 -04:00
rocky
7dacd509a8 Administrivia 2024-07-22 17:57:50 -04:00
rocky
e6ddaab691 Adminstiriva: bump to dev0 version 2024-07-22 05:16:10 -04:00
rocky
a35a19d230 Merge 2024-07-21 18:57:43 -04:00
rocky
85c224e7ab Merge branch 'master' into python-3.3-to-3.5 2024-07-21 18:57:37 -04:00
rocky
f9b20f6eda Get ready for release 3.9.2 2024-07-21 18:56:22 -04:00
rocky
829078c622 Merge branch 'master' into python-3.3-to-3.5 2024-07-21 18:36:24 -04:00
rocky
b0dd7f57c6 Lint 2024-07-21 18:36:12 -04:00
rocky
1d705b0451 Merge 2024-07-21 17:37:15 -04:00
rocky
1189deced5 Merge branch 'master' into python-3.3-to-3.5 2024-07-21 17:35:02 -04:00
rocky
1a3f2b8ab0 Misc lint 2024-07-21 17:34:06 -04:00
rocky
5580b2b795 Bump min xdis version 2024-07-21 12:53:34 -04:00
rocky
0dcef6ea69 Merge branch 'master' into python-3.3-to-3.5 2024-07-20 02:28:35 -04:00
rocky
aced47a020 Sync with 2.4 branch 2024-07-20 02:28:18 -04:00
rocky
f45f8788ef Merge branch 'master' into python-3.3-to-3.5 2024-07-18 19:31:17 -04:00
rocky
ce690f3586 Lint initialization 2024-07-18 19:30:47 -04:00
rocky
5901e78770 Merge branch 'master' into python-3.3-to-3.5 2024-07-18 10:22:28 -04:00
rocky
25675f216f Sync fragments with pysource (a little bit) 2024-07-18 10:20:55 -04:00
rocky
915ff5e59c Remove pre 3.5 BUILD_MAP customiztion...
it is not needed here.
2024-07-15 13:53:36 -04:00
rocky
b7e1c51243 Merge 2024-07-15 10:06:30 -04:00
rocky
12c5548a5c Merge branch 'master' into python-3.3-to-3.5 2024-07-15 10:06:25 -04:00
rocky
81922bdb23 Handle long dict litereals in 3.4- better...
Bracket in pseudo op COLLECTION_START ... BUILD_xx
2024-07-15 10:01:32 -04:00
rocky
1644370165 Handle long dict litereals in 3.4- better...
We detect them in tokenization and turn this into pseudo instructions
2024-07-15 09:46:48 -04:00
rocky
58c1512dc5 Merge branch 'master' into python-3.3-to-3.5 2024-07-15 08:01:08 -04:00
rocky
d731d32c11 Simplify BREAK_LOOP detection...
by making more us of linestart. At least for now...
2024-07-14 14:45:25 -04:00
rocky
04da2fb8df Improve 3.4 ifelse inside a lambda
Fixes #426
2024-07-13 22:46:31 -04:00
rocky
e64859639f Merge branch 'master' into python-3.3-to-3.5 2024-07-13 22:31:24 -04:00
rocky
9c6f2ee838 Improve 3.4 ifelse inside a lambda 2024-07-13 22:29:58 -04:00
rocky
389fc2360a 3.6 bug related to large whilestmt 2024-07-13 21:42:49 -04:00
rocky
7787166ddf Add grammar rule involving RETURN_END_IF 2024-07-13 17:47:21 -04:00
rocky
7a17c8c441 Merge branch 'master' into python-3.3-to-3.5 2024-07-13 17:45:15 -04:00
rocky
ea36ff9bb1 Add grammar rule involving RETURN_END_IF 2024-07-13 17:44:30 -04:00
rocky
4a3e113b35 Merge branch 'master' into python-3.3-to-3.5 2024-07-13 15:59:17 -04:00
rocky
049d7c21bb Add grammar rule involving RETURN_END_IF 2024-07-13 15:57:24 -04:00
rocky
953fab5274 Merge branch 'master' into python-3.3-to-3.5 2024-07-13 11:59:32 -04:00
rocky
e3579463ab Loosen what is allowed in whilestmt38...
Fixes #498
2024-07-13 11:58:27 -04:00
rocky
fa00af4b98 Merge branch 'master' into python-3.3-to-3.5 2024-07-13 09:52:42 -04:00
rocky
0627215e98 BUILD_MAP is different pre 3.5 2024-07-13 09:51:49 -04:00
rocky
30f6bb7987 Merge branch 'master' into python-3.3-to-3.5 2024-07-13 09:49:32 -04:00
rocky
6b139af560 BUILD_MAP is different pre 3.5 2024-07-13 09:49:00 -04:00
rocky
7b7c662a20 Adjust for 3.3 language 2024-07-13 07:28:22 -04:00
rocky
ae7fdccc7c Merge branch 'master' into python-3.3-to-3.5 2024-07-13 07:26:06 -04:00
rocky
d0dc879b37 Note that we can now use xdis a little more 2024-07-13 07:25:36 -04:00
rocky
cf30bfcd49 Merge branch 'master' into python-3.3-to-3.5 2024-07-12 21:31:28 -04:00
rocky
b28f3058fc Expand grammar check for ifelse continue for 2.7 2024-07-12 21:30:46 -04:00
rocky
c8241938ba Merge branch 'master' into python-3.3-to-3.5 2024-07-12 19:08:30 -04:00
rocky
703716ca6f Pick up recewnt try/except change from 2.5 2024-07-12 19:07:29 -04:00
rocky
14993d0af4 Add one more docstring 2024-07-12 14:48:07 -04:00
rocky
b53b286666 Merge branch 'master' into python-3.3-to-3.5 2024-07-12 14:16:19 -04:00
rocky
ad621efb7a Merge 2024-07-12 14:16:04 -04:00
rocky
cb2b90a94f Python 2.5 try/except reduce fix
Start getting aligner up to date
2024-07-12 14:15:04 -04:00
rocky
499f77e48b Merge branch 'master' into python-3.3-to-3.5 2024-07-12 13:05:17 -04:00
rocky
efbd6570b0 Update readmes 2024-07-12 13:02:45 -04:00
rocky
a42bef12d2 Remove a false negative test for try/except in 25 2024-07-12 12:39:27 -04:00
rocky
9d150e0707 Update copyright 2024-07-12 12:10:31 -04:00
rocky
35e64f51ee Merge branch 'master' into python-3.3-to-3.5 2024-07-12 11:38:44 -04:00
rocky
f030b3316c Fix some 2.5 parsing bugs 2024-07-12 11:21:48 -04:00
rocky
550da8c134 Merge branch 'master' into python-3.3-to-3.5 2024-07-12 10:17:42 -04:00
rocky
9450165109 Add if/then rule to assist 2.5 parsing 2024-07-12 10:17:05 -04:00
rocky
adcd72f6ed Merge branch 'master' into python-3.3-to-3.5 2024-07-12 08:38:11 -04:00
rocky
be825239c6 2.6 custom tryelse code is no longer needed?
If it turns out to be needed, add it back in a better way.
2024-07-12 08:37:05 -04:00
rocky
4394d46f64 Remove redundant list_comp() fn 2024-07-11 20:16:03 -04:00
rocky
771e8c9b99 Merge branch 'master' into python-3.3-to-3.5 2024-07-11 18:53:06 -04:00
rocky
b10dd0ea5b 2.6 bug appears in 2.4 and 2.5 2024-07-11 18:52:09 -04:00
rocky
c5e1368de7 Merge branch 'master' into python-3.3-to-3.5 2024-07-11 18:34:30 -04:00
rocky
6fe8a1d2ba Address long-standing Python 2.6 try/except bug
Fixes #405
2024-07-11 14:01:50 -04:00
rocky
b0b67e9f34 Fix some 2.6 bytecode bugs
scanner26: disassemble interface has changed
make_function2: was missing ParserError2 import
2024-07-11 12:06:52 -04:00
rocky
3c6e378cc4 Spelling corrections 2024-07-10 13:31:39 -04:00
rocky
51141ad06d Use set literals 2024-06-03 07:55:44 -04:00
rocky
acdf777a35 Sync with decompile3 2024-06-03 07:39:13 -04:00
rocky
404c46c6bb Better const key sorting 2024-06-03 07:18:37 -04:00
rocky
0b9a3c668c Remove workflows 3.7 CI testing
3.7 no longer is available on github workflows
2024-05-30 05:03:00 -04:00
rocky
3939466281 Merge hell 2024-05-30 04:47:35 -04:00
rocky
6b0c909460 Merge branch 'master' into python-3.3-to-3.5 2024-05-30 04:47:26 -04:00
rocky
6f2a837765 Better sorting of TABLE_DIRECT keys 2024-05-30 04:35:58 -04:00
rocky
39b4b83977 Small set literal change 2024-05-07 11:33:03 -04:00
rocky
458d4727dd Properly escape strings.
Backported from decompyle3
2024-03-25 06:42:06 -04:00
rocky
3b1d5bddd9 Correct name in docstring 2024-03-17 21:29:48 -04:00
rocky
b6b76d9b81 Keep pre-toml setup around for a little while 2024-03-16 03:49:17 -04:00
rocky
0f34fb6726 Administrivia 2024-03-16 03:37:43 -04:00
rocky
29edaaed0e Get ready for release 3.9.1 2024-03-16 03:07:28 -04:00
rocky
9128813798 Merge branch 'master' into python-3.3-to-3.5 2024-03-15 23:12:22 -04:00
rocky
b7eae4f360 Get ready for release 3.9.1 2024-03-15 23:09:33 -04:00
rocky
75d90b933c Merge branch 'master' into python-3.3-to-3.5 2024-03-15 22:43:29 -04:00
rocky
3aed87ac5e Get ready for release 3.9.1 2024-03-15 22:40:13 -04:00
rocky
af873f1e88 Merge branch 'master' into python-3.3-to-3.5 2024-03-15 22:38:54 -04:00
rocky
ee72f6d685 Get ready for release 3.9.1 2024-03-15 22:32:29 -04:00
rocky
bec88e4aaa Name phases "disassembly" and "tokenization" 2024-03-14 15:31:53 -04:00
rocky
8d6d8b31e0 Merge branch 'master' into python-3.3-to-3.5 2024-03-14 15:27:52 -04:00
rocky
85e5d72529 Adjust setup message 2024-03-14 15:21:14 -04:00
rocky
7209405b2c Adjust setup to correct version 2024-03-14 15:17:37 -04:00
rocky
b88af23406 Mis spelling corrections 2024-03-14 05:39:30 -04:00
rocky
a8f89fa006 Merge branch 'master' into python-3.3-to-3.5 2024-03-13 21:41:58 -04:00
rocky
daf54d2740 2.6 scanner show -A headers now 2024-03-13 21:39:35 -04:00
rocky
dc79ec3a25 Correct variable name 2024-03-13 21:09:25 -04:00
rocky
252f18400c Merge branch 'master' into python-3.3-to-3.5 2024-03-13 21:09:07 -04:00
rocky
bf59e3c65e Small variable name fix 2024-03-13 21:08:08 -04:00
rocky
bb5bec29f7 Merge branch 'master' into python-3.3-to-3.5 2024-03-13 21:06:58 -04:00
rocky
628b18fce7 rename assembly phases and tweak a err msg...
before tokenization -> disassembly
after tokenization -> tokenization
2024-03-13 21:02:27 -04:00
rocky
ad92f53e39 Merge branch 'master' into python-3.3-to-3.5 2024-03-08 04:35:18 -05:00
R. Bernstein
e6ff6033cf Merge pull request #489 from rocky/withasstmt-to-with_as
withasstmt -> with_as
2024-03-08 04:12:55 -05:00
rocky
156188f8bb withasstmt -> with_as
This matches Python's AST naamae better. Some linting and
sorting of dictionary keys done as well.
2024-03-08 04:10:33 -05:00
R. Bernstein
3724e02183 Merge pull request #488 from rocky/with-as-with-pass
Add context manager test...
2024-03-07 18:53:14 -05:00
rocky
8542df4639 Add context manager test...
handle degenerate 3.8 withas
2024-03-07 18:08:07 -05:00
R. Bernstein
b5c4e4b28b Merge pull request #487 from rocky/withasstmt-no-parens
simplify withas (for now)
2024-03-06 17:41:42 -05:00
rocky
f1169af582 simplify withas (for now) 2024-03-06 17:19:57 -05:00
rocky
5c0fd39e0b Merge branch 'master' into python-3.3-to-3.5 2024-03-02 12:03:15 -05:00
rocky
33f49849f5 Add some 3.3 and 3.4 stdlib tests back in 2024-03-02 12:02:40 -05:00
rocky
7a05a36f63 Merge branch 'master' into python-3.3-to-3.5 2024-03-02 11:54:53 -05:00
rocky
c499d0a60a Fix in 3.3 subclass detection in class closures 2024-03-02 11:54:11 -05:00
rocky
28e33f4b92 Merge branch 'master' into python-3.3-to-3.5 2024-03-02 07:04:36 -05:00
rocky
d2d4367dae Add 3.3 bytecode testing..
Also, correct ifelse detection in 3.3
2024-03-02 07:01:40 -05:00
rocky
29e413c13c Merge branch 'master' into python-3.3-to-3.5 2024-03-02 05:19:12 -05:00
rocky
c591f4e6e6 Administrivia 2024-03-02 05:18:56 -05:00
rocky
7c91694cf9 merge hell 2024-03-02 05:07:12 -05:00
rocky
ac9c7d1047 Merge branch 'master' into python-3.3-to-3.5 2024-03-02 05:07:05 -05:00
rocky
69c5d463e6 Add liberapay name 2024-03-02 04:59:20 -05:00
rocky
830a2ebf44 Sync with decompyle3 2024-03-02 04:32:26 -05:00
rocky
3721722764 Merge branch 'master' into python-3.3-to-3.5 2024-02-25 06:41:50 -05:00
rocky
2db15210c9 Merge branch 'master' into python-3.3-to-3.5 2024-02-25 06:12:05 -05:00
rocky
58f9935bd6 Merge branch 'master' into python-3.3-to-3.5 2024-02-25 06:09:10 -05:00
rocky
404517e426 Admnistrivia 2024-02-25 06:09:01 -05:00
rocky
e4127b34a5 Merge branch 'master' into python-3.3-to-3.5 2024-02-24 17:44:16 -05:00
rocky
df6f39cb26 Merge branch 'master' into python-3.3-to-3.5 2024-02-24 10:27:03 -05:00
rocky
e77ccba40e Merge hell 2024-02-24 07:15:47 -05:00
rocky
2fcb7a62e1 Merge branch 'master' into python-3.3-to-3.5 2024-02-24 07:12:07 -05:00
rocky
afb79f84e2 No f-string in this branch 2024-02-17 15:22:02 -05:00
rocky
1f462cf503 Merge branch 'master' into python-3.3-to-3.5 2024-02-17 15:21:08 -05:00
rocky
c0a86e6b9f Merge branch 'master' into python-3.3-to-3.5 2024-02-12 08:50:38 -05:00
rocky
909ec81b55 More administrivia 2024-02-12 08:50:31 -05:00
rocky
94e57f3ccf Merge branch 'master' into python-3.3-to-3.5 2024-02-12 08:17:09 -05:00
rocky
4cf0f83257 Merge branch 'master' into python-3.3-to-3.5 2024-02-12 01:38:59 -05:00
rocky
950dd05791 Merge hell 2024-02-11 23:40:42 -05:00
rocky
e9ff6136b5 Merge branch 'master' into python-3.3-to-3.5 2024-02-11 23:40:30 -05:00
rocky
f9f5a64c87 Attempt to fix annotation bugs 2024-02-11 19:14:50 -05:00
rocky
a4971ee27d Remove f-strings from merge from master 2024-02-11 12:33:54 -05:00
rocky
82a64b421d Handle annotations properly 2024-02-11 11:57:18 -05:00
rocky
c048b26d4e Merge branch 'master' into python-3.3-to-3.5 2024-02-11 11:57:12 -05:00
rocky
ece788e09e Merge hell 2024-02-11 09:18:43 -05:00
rocky
d8e212c9ea Merge branch 'master' into python-3.3-to-3.5 2024-02-11 09:11:03 -05:00
rocky
1e72250f79 Merge branch 'master' into python-3.3-to-3.5 2024-02-04 12:37:14 -05:00
rocky
ef92f08f56 Black files 2024-02-04 12:29:30 -05:00
rocky
bdc751f444 Merge branch 'master' into python-3.3-to-3.5 2024-02-04 12:25:41 -05:00
rocky
b0e139e6cc Partial merge 2024-02-04 12:16:17 -05:00
rocky
1e95ebd5f6 Bump 3.8 version to latest 2024-02-03 14:49:56 -05:00
rocky
d1dc5a404c Merge branch 'master' into python-3.3-to-3.5 2023-08-12 06:38:56 -04:00
rocky
ae75b4f677 Merge branch 'comprehension-in-lambda-parsing-bug' into python-3.3-to-3.5 2023-08-11 14:20:58 -04:00
rocky
18f253ffbe 3.3 compatibility 2023-07-29 12:57:52 -04:00
rocky
6b01da76ea Merge branch 'master' into python-3.3-to-3.5 2023-07-29 12:57:37 -04:00
rocky
f55febfbf0 Merge from master 2023-07-01 10:34:04 -04:00
rocky
df1772164c Merge from master 2023-07-01 10:33:04 -04:00
rocky
47f0d5cd69 Merge with master 2023-06-30 16:00:54 -04:00
rocky
4bd6e609dd formatting 2023-06-30 02:05:55 -04:00
rocky
0897d47afa Merge branch 'master' into python-3.3-to-3.5 2023-06-30 01:57:41 -04:00
rocky
b7ad271aa2 Revert 3.6ish type annotation 2023-04-17 23:09:21 -04:00
rocky
060c8df174 Merge branch 'master' into python-3.3-to-3.5 2023-04-17 23:07:38 -04:00
rocky
dba73d6f02 Merge branch 'master' into python-3.3-to-3.5 2023-04-08 21:49:22 -04:00
rocky
be855a3001 Renstate some code 2023-03-25 02:35:59 -04:00
rocky
0b8edba0dd Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2023-03-25 02:28:32 -04:00
rocky
5a2e5cf6bb Merge branch 'master' into python-3.3-to-3.5 2023-03-25 02:27:59 -04:00
rocky
655ab203ea Merge branch 'master' into python-3.3-to-3.5 2023-03-25 02:22:59 -04:00
rocky
793e9ced6a Merge branch 'master' into python-3.3-to-3.5 2023-01-24 21:49:38 -05:00
rocky
ee7fda2869 Remove a CircleCI test for 3.0-3.2...
until we can find an image that might run this
2023-01-16 09:03:14 -05:00
rocky
f2d141c466 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2023-01-16 03:51:43 -05:00
rocky
cb7bbbb2e1 Merge branch 'master' into python-3.3-to-3.5 2023-01-16 03:51:18 -05:00
rocky
d7fdafc1f7 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2023-01-16 03:41:55 -05:00
rocky
1cac7d50c1 Merge branch 'master' into python-3.3-to-3.5 2023-01-16 03:41:25 -05:00
rocky
4171dfc7e9 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2023-01-16 02:12:43 -05:00
rocky
df7310e8ca Merge branch 'make-fn-or-closure-with-annotatation' into python-3.3-to-3.5 2023-01-16 02:11:16 -05:00
rocky
8479e66add Annotate arg parsing 2023-01-16 01:22:39 -05:00
rocky
4281083641 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2023-01-14 10:04:43 -05:00
rocky
5102e5f6e0 Merge hell 2023-01-14 10:02:01 -05:00
rocky
bee35aa05d Merge branch 'master' into python-3.3-to-3.5 2023-01-14 10:01:57 -05:00
rocky
4828ae99a3 Merge branch 'master' into python-3.3-to-3.5 2023-01-14 09:43:28 -05:00
rocky
26b60f6fb8 Handle Python 3.4 MAKE_CLOSURE fns ...
Is done just like Python 3.3
2023-01-14 09:42:16 -05:00
rocky
18133794e6 Merge branch 'master' into python-3.3-to-3.5 2023-01-14 08:40:54 -05:00
rocky
499acce8e6 Merge branch 'master' into python-3.3-to-3.5 2023-01-14 00:06:14 -05:00
rocky
3ea0d67be9 Add check program for Python 3.3-3.5 2022-12-22 23:33:49 -05:00
rocky
f41a16b7e9 Merge branch 'master' into python-3.3-to-3.5 2022-12-22 23:21:59 -05:00
rocky
6ba779b915 Get ready for release 3.9.0 2022-12-22 23:12:54 -05:00
rocky
2b9887ce9b x#Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2022-12-01 17:42:44 -05:00
rocky
86ba02d5f2 Merge branch 'master' into python-3.3-to-3.5 2022-12-01 17:36:30 -05:00
rocky
d42fee1b50 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2022-11-27 05:02:42 -05:00
rocky
54e9de4a7d Merge branch 'master' into python-3.3-to-3.5 2022-11-27 05:01:44 -05:00
rocky
f8798945ab Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2022-11-05 10:37:51 -04:00
rocky
c1a5d3ce8d Merge branch 'master' into python-3.3-to-3.5 2022-11-05 10:32:52 -04:00
rocky
a941326a30 Add generator expression Python 3.0 .. 3.2 2022-11-05 10:13:21 -04:00
rocky
5b36e45805 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2022-11-05 00:28:40 -04:00
rocky
a774cc1892 Merge branch 'master' into python-3.3-to-3.5 2022-11-05 00:27:57 -04:00
rocky
e03274c78c Fix another 3.0 list comprehension parse 2022-11-05 00:25:32 -04:00
rocky
5ff3a54ed7 Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2022-11-04 02:06:36 -04:00
rocky
1323500a76 Merge branch 'master' into python-3.3-to-3.5 2022-11-04 02:06:00 -04:00
rocky
9923a4c775 More 3.0 lambda comphension fixes 2022-11-04 02:02:34 -04:00
rocky
dd20a38412 Sync with python-3.3-3.5 branch 2022-11-04 00:57:24 -04:00
rocky
b83bcb871a Merge branch 'python-3.3-to-3.5' into python-3.0-to-3.2 2022-11-04 00:56:50 -04:00
rocky
076a40c06d Merge branch 'master' into python-3.3-to-3.5 2022-11-04 00:54:56 -04:00
rocky
504845668c Merge branch 'master' into python-3.3-to-3.5 2022-11-04 00:50:01 -04:00
rocky
375101d960 Merge branch 'master' into python-3.3-to-3.5 2022-11-04 00:47:00 -04:00
rocky
2a393a408b Handle 3.0 list comprehensions properly 2022-11-04 00:36:22 -04:00
rocky
e596fb0917 Allow running from 3.0 2022-11-03 16:20:52 -04:00
rocky
0ce23288cb Merge branch 'master' into python-3.3-to-3.5 2022-11-03 15:23:32 -04:00
rocky
1ecceb6471 Merge branch 'master' into python-3.3-to-3.5 2022-10-16 19:34:23 -04:00
rocky
7d1b306b10 Merge branch 'master' into python-3.3-to-3.5 2022-10-16 18:25:32 -04:00
rocky
7ce05a1934 Merge branch 'master' into python-3.3-to-3.5 2022-10-16 17:51:46 -04:00
rocky
291b8e0f90 Merge branch 'master' into python-3.3-to-3.5 2022-09-30 03:34:58 -04:00
rocky
68c646f1bb Remove type annotations 2022-09-30 02:50:53 -04:00
rocky
28bd433c9a Merge branch 'master' into python-3.3-to-3.5 2022-09-30 02:47:02 -04:00
rocky
e1f41b724e Merge branch 'master' into python-3.3-to-3.5 2022-09-22 06:38:17 -04:00
rocky
2fc80fc747 Merge branch 'master' into python-3.3-to-3.5 2022-09-20 17:29:15 -04:00
rocky
a173f27e7c Merge branch 'master' into python-3.3-to-3.5 2022-09-16 15:47:33 -04:00
rocky
e4e9cb2758 Merge branch 'master' into python-3.3-to-3.5 2022-09-16 15:45:05 -04:00
rocky
3b3ff705f9 Merge branch 'master' into python-3.3-to-3.5 2022-08-23 21:42:05 -04:00
rocky
a59e9c1aa8 Merge branch 'master' into python-3.3-to-3.5 2022-08-23 17:08:42 -04:00
rocky
8483a5102b Merge branch 'master' into python-3.3-to-3.5 2022-08-23 07:43:26 -04:00
rocky
d03a4235df pre 3.6 tolerance 2022-07-07 01:58:40 -04:00
rocky
7a4df3226e Merge branch 'master' into python-3.3-to-3.5 2022-07-07 01:56:27 -04:00
rocky
b512b20b56 Merge branch 'master' into python-3.3-to-3.5 2022-07-04 07:10:49 -04:00
rocky
50f6625cd1 Merge branch 'master' into python-3.3-to-3.5 2022-06-08 12:53:50 -04:00
rocky
4096d310e4 Correct 2.5-7 relative import formatting 2022-05-14 19:38:09 -04:00
rocky
5c6c6c663d Bugs in 2.x relative import '.' and 1.x bytecode 2022-05-14 19:38:09 -04:00
rocky
8f09437537 Correct 2.x formatting "slice2" nonterminal 2022-05-14 19:38:09 -04:00
rocky
d89153f910 semi-black scanner26.py 2022-05-14 19:37:59 -04:00
rocky
b8856993d2 merge from master 2022-05-14 09:55:19 -04:00
rocky
4f6d3a3d7e Merge branch 'master' into python-3.3-to-3.5 2022-05-14 09:02:53 -04:00
rocky
e930c9c6ef Merge branch 'master' into python-3.3-to-3.5 2022-04-27 04:02:17 -04:00
rocky
3471d11dd5 Merge in literal speedups 2022-04-26 02:45:31 -04:00
rocky
2a0a6c904c Merge branch 'long-collection-python3' into python-3.3-to-3.5 2022-04-26 02:38:02 -04:00
rocky
2d6f31df97 Use attr insead of pattrr for non-strings 2022-04-26 02:35:34 -04:00
rocky
d8d8ed60d7 Python 3.3 tolerance 2022-04-25 07:56:41 -04:00
rocky
0f525c142d Python 3.3 tolerance 2022-04-25 07:53:36 -04:00
rocky
ee4d166e71 Merge branch 'master' into python-3.3-to-3.5 2022-04-25 07:44:10 -04:00
rocky
7720c8aa10 Merge branch 'master' into python-3.3-to-3.5 2022-04-21 05:34:38 -04:00
rocky
003ad0ceef Merge branch 'master' into python-3.3-to-3.5 2022-04-21 05:29:25 -04:00
rocky
aff0cd4baa Merge branch 'master' into python-3.3-to-3.5 2022-04-20 08:20:50 -04:00
rocky
dd98eb8764 Merge branch 'master' into python-3.3-to-3.5 2022-04-17 12:21:53 -04:00
rocky
ee439540da Merge branch 'master' into python-3.3-to-3.5 2022-04-17 11:43:28 -04:00
rocky
9539a5c95c Merge conflicts 2022-04-17 11:03:17 -04:00
rocky
6899f2bd96 Merge branch 'master' into python-3.3-to-3.5 2022-04-17 11:03:00 -04:00
rocky
97f8d91e35 Merge branch 'master' into python-3.3-to-3.5 2022-04-15 08:42:40 -04:00
rocky
b0250f4f9a Merge branch 'master' into python-3.3-to-3.5 2022-03-31 06:27:07 -04:00
rocky
f89a3e8fa1 Remove some 3.6ish type annotations 2022-03-04 05:16:12 -05:00
rocky
209f19c1da Some variable name changes...
and sync with master
2022-03-04 04:51:36 -05:00
rocky
76f7bae0a6 Merge branch 'master' into python-3.3-to-3.5 2022-03-04 04:48:50 -05:00
rocky
a93bec73cf merge hell 2022-01-14 08:04:33 -05:00
rocky
997942e235 Merge branch 'master' into python-3.3-to-3.5 2022-01-14 08:04:01 -05:00
rocky
7c4b82243b Merge branch 'master' into python-3.3-to-3.5 2022-01-03 22:08:46 -05:00
rocky
92c0534cd4 Merge branch 'master' into python-3.3-to-3.5 2022-01-01 22:42:02 -05:00
rocky
256d19d9b4 Merge branch 'master' into python-3.3-to-3.5 2021-12-31 11:42:11 -05:00
rocky
56f10a8cfa Merge branch 'master' into python-3.3-to-3.5 2021-12-31 11:33:26 -05:00
rocky
82d10e025c Merge branch 'master' into python-3.3-to-3.5 2021-12-31 11:29:11 -05:00
rocky
2ac85acca5 Merge branch 'master' into python-3.3-to-3.5 2021-12-26 19:05:27 -05:00
rocky
b96e1df14b Merge branch 'master' into python-3.3-to-3.5 2021-12-26 18:52:58 -05:00
rocky
90930b66ce Merge branch 'master' into python-3.3-to-3.5 2021-12-23 22:55:36 -05:00
rocky
164168e7f4 unmap_dict -> dict_unmap ...
This matches Python's AST (Dict) better. Variations or specializations
of an AST name, e.g. "unmap" should come at the end, not the beginning.
2021-12-23 22:24:45 -05:00
rocky
040ed20b59 Sync with master 2021-12-23 16:47:46 -05:00
rocky
f06bd69858 Sync with master 2021-12-23 16:44:53 -05:00
rocky
ef03e7151d Add operator precedence to -T output 2021-12-23 16:20:58 -05:00
rocky
5a7755e047 Merge branch 'master' into python-3.3-to-3.5 2021-12-17 06:23:29 -05:00
rocky
3aadd0574e Merge branch 'master' into python-3.3-to-3.5 2021-11-28 06:21:07 -05:00
rocky
eff663cc4e Merge branch 'master' into python-3.3-to-3.5 2021-11-28 06:19:20 -05:00
rocky
9caceed001 Administrivia 2021-11-28 06:19:07 -05:00
rocky
a11b290a81 Merge branch 'master' into python-3.3-to-3.5 2021-11-28 06:18:44 -05:00
rocky
bba9c577d1 Administrivia 2021-11-28 06:17:30 -05:00
rocky
c4baec28de No fstrings here 2021-11-24 15:38:28 -05:00
rocky
62da9f4583 Merge branch 'master' into python-3.3-to-3.5 2021-11-24 15:14:35 -05:00
rocky
890230b791 Merge branch 'master' into python-3.3-to-3.5 2021-11-21 14:12:54 -05:00
rocky
f72070e6d0 Administrivia - workflows CI 2021-11-07 10:21:56 -05:00
rocky
94832d654f Merge branch 'master' into python-3.3-to-3.5 2021-11-03 05:02:26 -04:00
rocky
77742532aa Merge branch 'master' into python-3.3-to-3.5 2021-11-03 03:02:13 -04:00
rocky
e233b2f63a Merge branch 'master' into python-3.3-to-3.5 2021-11-03 02:26:11 -04:00
rocky
0742f0b83f Specialize for Python 3.3-3.5 2021-11-03 01:56:41 -04:00
rocky
f36acf6faa Merge branch 'master' into python-3.3-to-3.5 2021-11-03 01:27:54 -04:00
rocky
96617c0895 Merge branch 'master' into python-3.3-to-3.5 2021-11-03 01:20:09 -04:00
rocky
e50cd1e07d Fix off-by-one in setup's 3.6 range comparison 2021-10-30 06:00:10 -04:00
rocky
c8c6f1a63d Merge hell 2021-10-29 22:29:15 -04:00
rocky
850500c7ad Merge branch 'master' into python-3.3-to-3.5 2021-10-29 22:25:36 -04:00
rocky
08ed185608 Merge branch 'master' into python-3.3-to-3.5 2021-10-28 18:46:08 -04:00
rocky
39d79217ca Merge hell 2021-10-26 06:47:35 -04:00
rocky
a2e34ab75c Merge branch 'master' into python-3.3-to-3.5 2021-10-26 06:19:01 -04:00
rocky
5c2af69925 Loosen check to allow running from 2.4-3.10
We still only can *decompile* 2.4-3.8
2021-10-26 06:08:17 -04:00
rocky
1b4b6b334e Merge branch 'master' into python-3.3-to-3.5 2021-10-25 09:09:51 -04:00
rocky
482dbb5c82 Modernize and sync with decompyle3 better 2021-10-25 09:04:12 -04:00
rocky
55ffaa1aff Merge branch 'master' into python-3.3-to-3.5 2021-10-24 01:52:52 -04:00
rocky
79d5790e3f Workflows CI adjusment 2021-10-23 16:06:02 -04:00
rocky
64b75625a9 Merge branch 'master' into python-3.3-to-3.5 2021-10-23 15:56:19 -04:00
rocky
5ddbea73f4 Merge branch 'master' into python-3.3-to-3.5 2021-10-23 09:50:29 -04:00
rocky
fad5089175 Administrivia 2021-10-23 08:33:39 -04:00
rocky
52262dc38a Merge hell 2021-10-23 08:27:47 -04:00
rocky
b61255535e Merge branch 'master' into python-3.3-to-3.5 2021-10-23 08:26:39 -04:00
rocky
ce58ed7434 CircleCI testing 2021-10-23 08:10:21 -04:00
rocky
01859ce820 Don not upgrade pip on older pythons 2021-10-23 07:53:50 -04:00
rocky
ada786e08c Administrivia 2021-10-21 16:38:12 -04:00
rocky
cfb5c442e2 Version twiddling 2021-10-21 16:33:42 -04:00
rocky
37f953c353 More version twiddling 2021-10-21 16:28:41 -04:00
rocky
4d84a723f4 Use right xdis branch 2021-10-21 16:22:57 -04:00
rocky
ddbfc168c5 CI testing 3.5, 3.6
Workflows doesn't go back before 3.5.
It is okay to use 3.6 in testing the 3.3-3.5 branch
2021-10-21 16:14:26 -04:00
rocky
a463220df2 Break out code for 3.3-3.5 versions 2021-10-21 16:12:39 -04:00
144 changed files with 2540 additions and 1647 deletions

View File

@@ -1,80 +0,0 @@
version: 2
filters:
branches:
only: master
jobs:
build:
working_directory: ~/rocky/python-uncompyle6
parallelism: 1
shell: /bin/bash --login
# CircleCI 2.0 does not support environment variables that refer to each other the same way as 1.0 did.
# If any of these refer to each other, rewrite them so that they don't or see https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables .
environment:
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
COMPILE: --compile
# To see the list of pre-built images that CircleCI provides for most common languages see
# https://circleci.com/docs/2.0/circleci-images/
docker:
- image: circleci/python:3.8
steps:
# Machine Setup
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
# The following `checkout` command checks out your code to your working directory. In 1.0 we did this implicitly. In 2.0 you can choose where in the course of a job your code should be checked out.
- checkout
# Prepare for artifact and test results collection equivalent to how it was done on 1.0.
# In many cases you can simplify this from what is generated here.
# 'See docs on artifact collection here https://circleci.com/docs/2.0/artifacts/'
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
# This is based on your 1.0 configuration file or project settings
- run:
working_directory: ~/rocky/python-uncompyle6
command: pip install --user virtualenv && pip install --user nose && pip install
--user pep8
# Dependencies
# This would typically go in either a build or a build-and-test job when using workflows
# Restore the dependency cache
- restore_cache:
keys:
- v2-dependencies-{{ .Branch }}-
# fallback to using the latest cache if no exact match is found
- v2-dependencies-
- run:
command: | # Use pip to install dependengcies
sudo pip install --user --upgrade setuptools
# Until the next release
sudo pip install git+https://github.com/rocky/python-xdis#egg=xdis
pip install --user -e .
pip install --user -r requirements-dev.txt
# Save dependency cache
- save_cache:
key: v2-dependencies-{{ .Branch }}-{{ epoch }}
paths:
# This is a broad list of cache paths to include many possible development environments
# You can probably delete some of these entries
- vendor/bundle
- ~/virtualenvs
- ~/.m2
- ~/.ivy2
- ~/.bundle
- ~/.cache/bower
# Test
# This would typically be a build job when using workflows, possibly combined with build
# This is based on your 1.0 configuration file or project settings
- run: sudo python ./setup.py develop && make check-3.6
- run: cd ./test/stdlib && bash ./runtests.sh 'test_[p-z]*.py'
# Teardown
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
# Save test results
- store_test_results:
path: /tmp/circleci-test-results
# Save artifacts
- store_artifacts:
path: /tmp/circleci-artifacts
- store_artifacts:
path: /tmp/circleci-test-results
# The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large

2
.github/FUNDING.yml vendored
View File

@@ -6,7 +6,7 @@ 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
liberapay: rocky
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']

View File

@@ -1,31 +0,0 @@
name: uncompyle6 (osx)
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: macos-latest
strategy:
matrix:
os: [macOS]
python-version: [3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Until the next xdis release
pip install git+https://github.com/rocky/python-xdis#egg=xdis
pip install -e .
pip install -r requirements-dev.txt
- name: Test uncompyle6
run: |
make check

View File

@@ -1,30 +0,0 @@
name: uncompyle6 (ubuntu)
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Until the next xdis release
pip install git+https://github.com/rocky/python-xdis#egg=xdis
pip install -e .
pip install -r requirements-dev.txt
- name: Test uncompyle6
run: |
make check

View File

@@ -1,31 +0,0 @@
name: uncompyle6 (windows)
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: macos-latest
strategy:
matrix:
os: [windows]
python-version: [3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
# Until the next xdis release
pip install git+https://github.com/rocky/python-xdis#egg=xdis
pip install -e .
pip install -r requirements-dev.txt
- name: Test uncompyle6
run: |
make check

1
.gitignore vendored
View File

@@ -17,6 +17,7 @@
/dist
/how-to-make-a-release.txt
/nose-*.egg
/pycharm-venv
/tmp
/uncompyle6.egg-info
/unpyc

View File

@@ -1,22 +0,0 @@
default_language_version:
python: python
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict
- id: debug-statements
stages: [commit]
- id: end-of-file-fixer
stages: [commit]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
stages: [commit]
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
language_version: python3
stages: [commit]

View File

@@ -19,17 +19,17 @@
TL;DR (too long; didn't read)
* Don't do something illegal. And don't ask me to do something illegal or help you do something illegal
* We already have an infinite supply of decompilation bugs that need fixing, and an automated mechanism for finding more. Decompilation bugs get addressed by easiness to fix and by whim. If you expect yours to be fixed ahead of those, you need to justify why.
* Don't do something illegal. And don't ask me to do something illegal or help you do something illegal.
* We already have an infinite supply of decompilation bugs that need fixing, and an automated mechanism for finding more. Decompilation bugs get addressed by easiness to fix and by whim. If you expect yours to be fixed ahead of those, you need to justify why. You can ask for a hand-assisted decompilation, but that is expensive and beyond what most are willing to spend. A $100 fee is needed just to look at the bytecode.
* When asking for help, you may be asked for what you've tried on your own first. There are plenty of sources of information about this code.
* If you are looking for *timely* help or support, well, that is typically known as a _paid_ service. I don't really have a mechanism for that since I have a full-time job. But supporting the project is an approximation.
* Submitting a bug or issue report that is likely to get acted upon may require a bit of effort on your part to make it easy for the problem solver. If you are not willing to do that, please don't waste our time. As indicated above, supporting the project will increase the likelihood of your issue getting noticed and acted upon.
* Bugs get fixed, slowly. Sometimes on the order of months or years. If you are looking for *timely* help or support, that is typically known as a _paid_ service.
* Submitting a bug or issue report that is likely to get acted upon may require a bit of effort on your part to make it easy for the problem solver. If you are not willing to do that, please don't waste your or our time. Bug report may be closed with about as much thought and care as apparent in the effort to create the bug. Supporting the project however, does increase the likelihood of your issue getting noticed and acted upon.
# Ethics
I do not condone using this program for unethical or illegal purposes. More detestable, at least to me, is asking for help to assist you in something that might not legitimate.
Do not use this program for unethical or illegal purposes. More detestable, at least to me, is asking for help to assist you in something that might not legitimate.
Don't use the issue tracker for such solicitations. To try to stave off illegitimate behavior, you should note that the issue tracker, the code, and bugs mentioned in that are in the open: there is no
Don't use the issue tracker for such unethical or illegal solicitations. To try to stave off illegitimate behavior, you should note that the issue tracker, the code, and bugs mentioned in that are in the open: there is no
confidentiality. You may be asked about the authorship or claimed ownership of the bytecode. If I think something is not quite right, I may label the issue questionable which may make the it easier those who are looking for illegal activity.
@@ -37,13 +37,13 @@ confidentiality. You may be asked about the authorship or claimed ownership of t
For many open-source projects bugs where the expectation is that bugs are rare, reporting bugs in a *thoughtful* way can be helpful. See also [How to Ask Questions the Smart Way](http://www.catb.org/~esr/faqs/smart-questions.html).
In this project though, most of the bug reports boil down to the something like: I am trying to reverse engineer some code that I am not the author/owner and that person doesn't want me to have access to. I am hitting a problem somewhere along the line which might have to do with decompilation, but it could be something else like how the bytecode was extracted, some problem in deliberately obfuscated code, or the use some kind of Python bytecode version that isn't supported by the decompiler.
In this project though, most of the bug reports boil down to the something like: I am trying to reverse engineer some code that I am not the author/owner and that person doesn't want me to have access to. I am hitting a problem somewhere along the line which might have to do with decompilation. But it could be something else like how the bytecode was extracted, some problem in deliberately obfuscated code, or the use some kind of Python bytecode version that isn't supported by the decompiler. Gee this stuff is complicated, here's an open source project, so maybe someone there will help me figure stuff out.
While you are free to report these, unless you sponsor the project, I may close them with about the same amount of effort spent that I think was used to open the report for them. And if you spent a considerable amount of time to create the bug report but didn't follow instructions given here and in the issue template, I am sorry in advance. Just go back, read, and follow instructions.
While you are free to report bugs, unless you sponsor the project, I may close them with about the same amount of effort spent that I think was used to open the report for them. And if you spent a considerable amount of time to create the bug report but didn't follow instructions given here and in the issue template, I am sorry in advance. Just go back, read, and follow instructions.
This project already has an infinite supply of bugs that have been narrowed to the most minimal form and where I have source code to compare against. And in the unlikely event this supply runs out, I have automated means for generating *another* infinite supply.
In this project the task of justifying why addressing your bug is of use to the community, and why it should be prioritized over the others, is the bug reporter's responsibility.
The task of justifying why addressing your bug is of use to the community, and why it should be prioritized over the others, is the bug reporter's responsibility.
While in the abstract, I have no problem answering questions about how to read a Python traceback or install Python software, or trying to understand what is going wrong in your particular setup, I am not a paid support person and there other things I'd rather be doing with my limited volunteer time. So save us both time, effort, and aggravation: use other avenues like StackOverflow. Again, justifying why you should receive unpaid help is the help requester's responsibility.

26
NEWS.md
View File

@@ -1,3 +1,29 @@
3.9.2: 2024-07-21
=================
- track xdis API changes
- Bug fixes and lint
3.9.1: 2024-05-15
=================
Lots of changes major changes. track xdis API has changes.
Separate Phases more clearly:
* disassembly
* tokenization
* parsing
* abstracting to AST (more is done in newer projects)
* printing
Although we do not decompile bytecode greater than 3.8, code supports running from up to 3.12.
Many bugs fixed.
A lot of Linting and coding style modernization.
Work done in preparation for Blackhat Asia 2024
3.9.0: 2022-12-22
=================

361
PKG-INFO
View File

@@ -1,10 +1,355 @@
Metadata-Version: 2.0
Metadata-Version: 1.1
Name: uncompyle6
Version: 2.0.1
Summary: Python byte-code to source-code converter
Home-page: http://github.com/rocky/python-uncompyle6
Author: Rocky
Version: 3.9.1
Summary: Python cross-version byte-code decompiler
Home-page: https://github.com/rocky/python-uncompyle6/
Author: Rocky Bernstein, Hartmut Goebel, John Aycock, and others
Author-email: rb@dustyfeet.com
License: MIT
Description: UNKNOWN
Platform: UNKNOWN
License: GPL3
Description: |buildstatus| |Pypi Installs| |Latest Version| |Supported Python Versions|
|packagestatus|
.. contents::
uncompyle6
==========
A native Python cross-version decompiler and fragment decompiler.
The successor to decompyle, uncompyle, and uncompyle2.
Introduction
------------
*uncompyle6* translates Python bytecode back into equivalent Python
source code. It accepts bytecodes from Python version 1.0 to version
3.8, spanning over 24 years of Python releases. We include Dropbox's
Python 2.5 bytecode and some PyPy bytecodes.
Why this?
---------
Ok, I'll say it: this software is amazing. It is more than your
normal hacky decompiler. Using compiler_ technology, the program
creates a parse tree of the program from the instructions; nodes at
the upper levels that look a little like what might come from a Python
AST. So we can really classify and understand what's going on in
sections of Python bytecode.
Building on this, another thing that makes this different from other
CPython bytecode decompilers is the ability to deparse just
*fragments* of source code and give source-code information around a
given bytecode offset.
I use the tree fragments to deparse fragments of code *at run time*
inside my trepan_ debuggers_. For that, bytecode offsets are recorded
and associated with fragments of the source code. This purpose,
although compatible with the original intention, is yet a little bit
different. See this_ for more information.
Python fragment deparsing given an instruction offset is useful in
showing stack traces and can be incorporated into any program that
wants to show a location in more detail than just a line number at
runtime. This code can be also used when source-code information does
not exist and there is just bytecode. Again, my debuggers make use of
this.
There were (and still are) a number of decompyle, uncompyle,
uncompyle2, uncompyle3 forks around. Many of them come basically from
the same code base, and (almost?) all of them are no longer actively
maintained. One was really good at decompiling Python 1.5-2.3, another
really good at Python 2.7, but that only. Another handles Python 3.2
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 decompyle3_.
This demonstrably does the best in decompiling Python across all
Python versions. And even when there is another project that only
provides decompilation for subset of Python versions, we generally do
demonstrably better for those as well.
How can we tell? By taking Python bytecode that comes distributed with
that version of Python and decompiling these. Among those that
successfully decompile, we can then make sure the resulting programs
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 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
------------
The code in the git repository can be run from Python 2.4 to the
latest Python version, with the exception of Python 3.0 through
3.2. Volunteers are welcome to address these deficiencies if there a
desire to do so.
The way it does this though is by segregating consecutive Python versions into
git branches:
master
Python 3.6 and up (uses type annotations)
python-3.3-to-3.5
Python 3.3 through 3.5 (Generic Python 3)
python-2.4
Python 2.4 through 2.7 (Generic Python 2)
PyPy 3-2.4 and later works as well.
The bytecode files it can read have been tested on Python
bytecodes from versions 1.4, 2.1-2.7, and 3.0-3.8 and later PyPy
versions.
Installation
------------
You can install from PyPI using the name ``uncompyle6``::
pip install uncompyle6
To install from source code, this project uses setup.py, so it follows the standard Python routine::
$ pip install -e . # set up to run from source tree
or::
$ python setup.py install # may need sudo
A GNU Makefile is also provided so :code:`make install` (possibly as root or
sudo) will do the steps above.
Running Tests
-------------
::
make check
A GNU makefile has been added to smooth over setting running the right
command, and running tests from fastest to slowest.
If you have remake_ installed, you can see the list of all tasks
including tests via :code:`remake --tasks`
Usage
-----
Run
::
$ uncompyle6 *compiled-python-file-pyc-or-pyo*
For usage help:
::
$ uncompyle6 -h
Verification
------------
In older versions of Python it was possible to verify bytecode by
decompiling bytecode, and then compiling using the Python interpreter
for that bytecode version. Having done this, the bytecode produced
could be compared with the original bytecode. However as Python's code
generation got better, this no longer was feasible.
If you want Python syntax verification of the correctness of the
decompilation process, add the :code:`--syntax-verify` option. However since
Python syntax changes, you should use this option if the bytecode is
the right bytecode for the Python interpreter that will be checking
the syntax.
You can also cross compare the results with another version of
`uncompyle6` since there are sometimes regressions in decompiling
specific bytecode as the overall quality improves.
For Python 3.7 and 3.8, the code in decompyle3_ is generally
better.
Or try specific another python decompiler like uncompyle2_, unpyc37_,
or pycdc_. Since the later two work differently, bugs here often
aren't in that, and vice versa.
There is an interesting class of these programs that is readily
available give stronger verification: those programs that when run
test themselves. Our test suite includes these.
And Python comes with another a set of programs like this: its test
suite for the standard library. We have some code in :code:`test/stdlib` to
facilitate this kind of checking too.
Known Bugs/Restrictions
-----------------------
The biggest known and possibly fixable (but hard) problem has to do
with handling control flow. (Python has probably the most diverse and
screwy set of compound statements I've ever seen; there
are "else" clauses on loops and try blocks that I suspect many
programmers don't know about.)
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 pretty good for Python 2
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 strongest around 3.4 or
3.3 and drops off as you move further away from those versions. Python
3.0 is weird in that it in some ways resembles 2.6 more than it does
3.1 or 2.7. Python 3.6 changes things drastically by using word codes
rather than byte codes. As a result, the jump offset field in a jump
instruction argument has been reduced. This makes the :code:`EXTENDED_ARG`
instructions are now more prevalent in jump instruction; previously
they had been rare. Perhaps to compensate for the additional
:code:`EXTENDED_ARG` instructions, additional jump optimization has been
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 3.8 removes :code:`SETUP_LOOP`, :code:`SETUP_EXCEPT`,
:code:`BREAK_LOOP`, and :code:`CONTINUE_LOOP`, instructions which may
make control-flow detection harder, lacking the more sophisticated
control-flow analysis that is planned. We'll see.
Currently not all Python magic numbers are supported. Specifically in
some versions of Python, notably Python 3.6, the magic number has
changes several times within a version.
**We support only released versions, not candidate versions.** Note
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 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_ or otherwise obfuscated code. For
PJOrion try: PJOrion Deobfuscator_ to unscramble the bytecode to get
valid bytecode before trying this tool; pydecipher_ might help with that.
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. `Pydeinstaller <https://github.com/charles-dyfis-net/pydeinstaller>`_ may help with unpacking Pyinstaller bundlers.
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.
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 decompyle3. Volunteers are welcome to do so.
You may run across a bug, that you want to report. Please do so after
reading `How to report a bug
<https://github.com/rocky/python-uncompyle6/blob/master/HOW-TO-REPORT-A-BUG.md>`_ and
follow the `instructions when opening an issue <https://github.com/rocky/python-uncompyle6/issues/new?assignees=&labels=&template=bug-report.md>`_.
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 and 3.8. Changes in that will get migrated back here.
* https://code.google.com/archive/p/unpyc3/ : supports Python 3.2 only. The above projects use a different decompiling technique than what is used here. Currently unmaintained.
* https://github.com/figment/unpyc3/ : fork of above, but supports Python 3.3 only. Includes some fixes like supporting function annotations. Currently unmaintained.
* 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.
* `How to report a bug <https://github.com/rocky/python-uncompyle6/blob/master/HOW-TO-REPORT-A-BUG.md>`_
* The HISTORY_ file.
* https://github.com/rocky/python-xdis : Cross Python version disassembler
* https://github.com/rocky/python-xasm : Cross Python version assembler
* https://github.com/rocky/python-uncompyle6/wiki : Wiki Documents which describe the code and aspects of it in more detail
* https://github.com/zrax/pycdc : The README for this C++ code says it aims to support all versions of Python. You can aim your slign shot for the moon too, but I doubt you are going to hit it. This code 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/trepan3k
.. _compiler: https://github.com/rocky/python-uncompyle6/wiki/How-does-this-code-work%3F
.. _HISTORY: https://github.com/rocky/python-uncompyle6/blob/master/HISTORY.md
.. _report_bug: https://github.com/rocky/python-uncompyle6/blob/master/HOW-TO-REPORT-A-BUG.md
.. _debuggers: https://pypi.python.org/pypi/trepan3k
.. _remake: https://bashdb.sf.net/remake
.. _pycdc: https://github.com/zrax/pycdc
.. _decompyle3: https://github.com/rocky/python-decompile3
.. _uncompyle2: https://github.com/wibiti/uncompyle2
.. _unpyc37: https://github.com/andrew-tavera/unpyc37
.. _this: https://github.com/rocky/python-uncompyle6/wiki/Deparsing-technology-and-its-use-in-exact-location-reporting
.. |buildstatus| image:: https://travis-ci.org/rocky/python-uncompyle6.svg
:target: https://travis-ci.org/rocky/python-uncompyle6
.. |packagestatus| image:: https://repology.org/badge/vertical-allrepos/python:uncompyle6.svg
:target: https://repology.org/project/python:uncompyle6/versions
.. _PJOrion: http://www.koreanrandom.com/forum/topic/15280-pjorion-%D1%80%D0%B5%D0%B4%D0%B0%D0%BA%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5-%D0%BA%D0%BE%D0%BC%D0%BF%D0%B8%D0%BB%D1%8F%D1%86%D0%B8%D1%8F-%D0%B4%D0%B5%D0%BA%D0%BE%D0%BC%D0%BF%D0%B8%D0%BB%D1%8F%D1%86%D0%B8%D1%8F-%D0%BE%D0%B1%D1%84
.. _pydecipher: https://github.com/mitre/pydecipher
.. _Deobfuscator: https://github.com/extremecoders-re/PjOrion-Deobfuscator
.. _Py2EXE: https://en.wikipedia.org/wiki/Py2exe
.. |Supported Python Versions| image:: https://img.shields.io/pypi/pyversions/uncompyle6.svg
.. |Latest Version| image:: https://badge.fury.io/py/uncompyle6.svg
:target: https://badge.fury.io/py/uncompyle6
.. |Pypi Installs| image:: https://pepy.tech/badge/uncompyle6/month
Platform: uncompyle6
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.4
Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.0
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Debuggers
Classifier: Topic :: Software Development :: Libraries :: Python Modules

View File

@@ -162,7 +162,7 @@ the right bytecode for the Python interpreter that will be checking
the syntax.
You can also cross compare the results with another version of
`uncompyle6` since there are sometimes regressions in decompiling
*uncompyle6* since there are sometimes regressions in decompiling
specific bytecode as the overall quality improves.
For Python 3.7 and 3.8, the code in decompyle3_ is generally
@@ -265,7 +265,7 @@ 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 decompyle3. Volunteers are welcome to do so.
the fixes in *decompyle3*. Any volunteers?
You may run across a bug, that you want to report. Please do so after
reading `How to report a bug
@@ -274,11 +274,15 @@ follow the `instructions when opening an issue <https://github.com/rocky/python-
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.
issues above the queue of other things I might be doing instead. In
rare situtations, I can do a hand decompilation of bytecode for a fee.
However this is expansive, usually beyond what most people are willing
to spend.
See Also
--------
* https://rocky.github.io/blackhat-asia-2024-additional/all-notes-print.html : How to Read and Write a High-Level Bytecode Decompiler: ``uncompyle6`` ``decompyle3`` -- BlackHat 2024 Asia (`video <https://www.youtube.com/watch?v=NA77SFncppE>`_. A big thanks to the Organizers and Reviewers for letting me speak. This kind of thing encourages me to work on projects like this.
* https://github.com/rocky/python-decompile3 : Much smaller and more modern code, focusing on 3.7 and 3.8. Changes in that will get migrated back here.
* https://code.google.com/archive/p/unpyc3/ : supports Python 3.2 only. The above projects use a different decompiling technique than what is used here. Currently unmaintained.
* https://github.com/figment/unpyc3/ : fork of above, but supports Python 3.3 only. Includes some fixes like supporting function annotations. Currently unmaintained.
@@ -303,8 +307,8 @@ See Also
.. _uncompyle2: https://github.com/wibiti/uncompyle2
.. _unpyc37: https://github.com/andrew-tavera/unpyc37
.. _this: https://github.com/rocky/python-uncompyle6/wiki/Deparsing-technology-and-its-use-in-exact-location-reporting
.. |buildstatus| image:: https://travis-ci.org/rocky/python-uncompyle6.svg
:target: https://travis-ci.org/rocky/python-uncompyle6
.. |buildstatus| image:: https://circleci.com/gh/rocky/python-uncompyle6.svg?style=svg
:target: https://app.circleci.com/pipelines/github/rocky/python-uncompyle6
.. |packagestatus| image:: https://repology.org/badge/vertical-allrepos/python:uncompyle6.svg
:target: https://repology.org/project/python:uncompyle6/versions
.. _PJOrion: http://www.koreanrandom.com/forum/topic/15280-pjorion-%D1%80%D0%B5%D0%B4%D0%B0%D0%BA%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5-%D0%BA%D0%BE%D0%BC%D0%BF%D0%B8%D0%BB%D1%8F%D1%86%D0%B8%D1%8F-%D0%B4%D0%B5%D0%BA%D0%BE%D0%BC%D0%BF%D0%B8%D0%BB%D1%8F%D1%86%D0%B8%D1%8F-%D0%BE%D0%B1%D1%84

0
__init__.py Normal file
View File

View File

@@ -62,6 +62,8 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Debuggers",
"Topic :: Software Development :: Libraries :: Python Modules",
@@ -77,7 +79,7 @@ entry_points = {
]
}
ftp_url = None
install_requires = ["click", "spark-parser >= 1.8.9, < 1.9.0", "xdis >= 6.0.8, < 6.2.0"]
install_requires = ["click", "spark-parser >= 1.8.9, < 1.9.2", "xdis >= 6.1.1, < 6.2.0"]
license = "GPL3"
mailing_list = "python-debugger@googlegroups.com"

1
admin-tools/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/.python-version

View File

@@ -0,0 +1,31 @@
#!/bin/bash
# Run tests over all Python versions in branch python-3.0-3.2
set -e
function finish {
cd $owd
}
owd=$(pwd)
trap finish EXIT
cd $(dirname ${BASH_SOURCE[0]})
if ! source ./pyenv-3.0-3.2-versions ; then
exit $?
fi
if ! source ./setup-python-3.0.sh ; then
exit $?
fi
cd ..
for version in $PYVERSIONS; do
echo --- $version ---
if ! pyenv local $version ; then
exit $?
fi
make clean && python setup.py develop
if ! make check ; then
exit $?
fi
echo === $version ===
done
finish

0
admin-tools/check-3.3-3.5-versions.sh Normal file → Executable file
View File

View File

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

View File

@@ -3,9 +3,9 @@ PACKAGE=uncompyle6
# FIXME put some of the below in a common routine
function finish {
cd $owd
cd $make_dist_uncompyle6_owd
}
owd=$(pwd)
make_dist_uncompyle6_owd=$(pwd)
trap finish EXIT
cd $(dirname ${BASH_SOURCE[0]})
@@ -21,6 +21,11 @@ source $PACKAGE/version.py
echo $__version__
for pyversion in $PYVERSIONS; do
echo --- $pyversion ---
if [[ ${pyversion:0:4} == "pypy" ]] ; then
echo "$pyversion - PyPy does not get special packaging"
continue
fi
if ! pyenv local $pyversion ; then
exit $?
fi
@@ -41,3 +46,4 @@ tarball=dist/${PACKAGE}-${__version_}_-tar.gz
if [[ -f $tarball ]]; then
rm -v dist/${PACKAGE}-${__version__}-tar.gz
fi
finish

View File

@@ -0,0 +1,49 @@
#!/bin/bash
PACKAGE=uncompyle6
# FIXME put some of the below in a common routine
function finish {
cd $uncompyle6_30_make_dist_owd
}
cd $(dirname ${BASH_SOURCE[0]})
uncompyle6_30_make_dist_owd=$(pwd)
trap finish EXIT
if ! source ./pyenv-3.0-3.2-versions ; then
exit $?
fi
if ! source ./setup-python-3.0.sh ; then
exit $?
fi
cd ..
source $PACKAGE/version.py
echo $__version__
for pyversion in $PYVERSIONS; do
echo --- $pyversion ---
if [[ ${pyversion:0:4} == "pypy" ]] ; then
echo "$pyversion - PyPy does not get special packaging"
continue
fi
if ! pyenv local $pyversion ; then
exit $?
fi
# pip bdist_egg create too-general wheels. So
# we narrow that by moving the generated wheel.
# Pick out first two number of version, e.g. 3.5.1 -> 35
first_two=$(echo $pyversion | cut -d'.' -f 1-2 | sed -e 's/\.//')
rm -fr build
python setup.py bdist_egg bdist_wheel
mv -v dist/${PACKAGE}-$__version__-{py2.py3,py$first_two}-none-any.whl
echo === $pyversion ===
done
python ./setup.py sdist
tarball=dist/${PACKAGE}-${__version__}.tar.gz
if [[ -f $tarball ]]; then
mv -v $tarball dist/${PACKAGE}_31-${__version__}.tar.gz
fi
finish

View File

@@ -3,11 +3,11 @@ PACKAGE=uncompyle6
# FIXME put some of the below in a common routine
function finish {
cd $owd
cd $uncompyle6_33_make_owd
}
cd $(dirname ${BASH_SOURCE[0]})
owd=$(pwd)
uncompyle6_33_make_owd=$(pwd)
trap finish EXIT
if ! source ./pyenv-3.3-3.5-versions ; then
@@ -22,6 +22,11 @@ source $PACKAGE/version.py
echo $__version__
for pyversion in $PYVERSIONS; do
echo --- $pyversion ---
if [[ ${pyversion:0:4} == "pypy" ]] ; then
echo "$pyversion - PyPy does not get special packaging"
continue
fi
if ! pyenv local $pyversion ; then
exit $?
fi
@@ -33,6 +38,12 @@ for pyversion in $PYVERSIONS; do
rm -fr build
python setup.py bdist_egg bdist_wheel
mv -v dist/${PACKAGE}-$__version__-{py2.py3,py$first_two}-none-any.whl
echo === $pyversion ===
done
python ./setup.py sdist
tarball=dist/${PACKAGE}-${__version__}.tar.gz
if [[ -f $tarball ]]; then
mv -v $tarball dist/${PACKAGE}_31-${__version__}.tar.gz
fi
finish

View File

@@ -3,11 +3,11 @@ PACKAGE=uncompyle6
# FIXME put some of the below in a common routine
function finish {
cd $owd
cd $make_uncompyle6_newest_owd
}
cd $(dirname ${BASH_SOURCE[0]})
owd=$(pwd)
make_uncompyle6_newest_owd=$(pwd)
trap finish EXIT
if ! source ./pyenv-newest-versions ; then
@@ -22,6 +22,11 @@ source $PACKAGE/version.py
echo $__version__
for pyversion in $PYVERSIONS; do
echo --- $pyversion ---
if [[ ${pyversion:0:4} == "pypy" ]] ; then
echo "$pyversion - PyPy does not get special packaging"
continue
fi
if ! pyenv local $pyversion ; then
exit $?
fi
@@ -36,3 +41,4 @@ for pyversion in $PYVERSIONS; do
done
python ./setup.py sdist
finish

View File

@@ -1,7 +1,7 @@
#/bin/bash
owd=$(pwd)
uncompyle6_merge_24_owd=$(pwd)
cd $(dirname ${BASH_SOURCE[0]})
if . ./setup-python-2.4.sh; then
git merge python-3.0-to-3.2
fi
cd $owd
cd $uncompyle6_merge_24_owd

View File

@@ -1,7 +1,7 @@
#/bin/bash
owd=$(pwd)
uncompyle6_merge_30_owd=$(pwd)
cd $(dirname ${BASH_SOURCE[0]})
if . ./setup-python-3.0.sh; then
git merge python-3.3-to-3.5
fi
cd $owd
cd $uncompyle6_merge_30_owd

View File

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

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

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

View File

@@ -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.10 3.3.7 3.4.10'
export PYVERSIONS=' 3.3.7 3.4.10 3.5.10 '

View File

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

View File

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

View File

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

View File

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

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

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

View File

@@ -123,6 +123,7 @@ def test_grammar():
opcode_set.add("THEN")
check_tokens(tokens, opcode_set)
elif PYTHON_VERSION_TRIPLE[:2] == (3, 4):
ignore_set.add("LOAD_ARG") # Used in grammar for comprehension. But not in 3.4
ignore_set.add("LOAD_CLASSNAME")
ignore_set.add("STORE_LOCALS")
opcode_set = set(s.opc.opname).union(ignore_set)

View File

@@ -4,6 +4,6 @@ pytest
-e .
Click~=7.0
xdis>=6.0.4
xdis >= 6.1.0, < 6.2.0
configobj~=5.0.6
setuptools~=65.5.1
setuptools

71
setup-pretoml.py Normal file
View File

@@ -0,0 +1,71 @@
#!/usr/bin/env python
import sys
import setuptools
"""Setup script for the 'uncompyle6' distribution."""
SYS_VERSION = sys.version_info[0:2]
if SYS_VERSION < (3, 6):
mess = "Python Release 3.6 .. 3.12 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 SYS_VERSION >= (3, 6):
mess += (
"\nFor your Python, version %s, use the master code/branch."
% sys.version[0:3]
)
if (3, 0) >= SYS_VERSION < (3, 3):
mess += (
"\nFor your Python, version %s, use the python-3.0-to-3.2 code/branch."
% sys.version[0:3]
)
if (3, 3) >= SYS_VERSION < (3, 6):
mess += (
"\nFor your Python, version %s, use the python-3.3-to-3.5 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]
)
print(mess)
raise Exception(mess)
from __pkginfo__ import (
__version__,
author,
author_email,
classifiers,
entry_points,
install_requires,
license,
long_description,
modname,
py_modules,
short_desc,
web,
zip_safe,
)
setuptools.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=setuptools.find_packages(),
py_modules=py_modules,
test_suite="nose.collector",
url=web,
version=__version__,
zip_safe=zip_safe,
)

View File

@@ -12,10 +12,11 @@ doc_files = README.rst
# examples/
[bdist_wheel]
universal=1
universal = no
[metadata]
description_file = README.rst
licences_files = COPYING
[flake8]
# max-line-length setting: NO we do not want everyone writing 120-character lines!

View File

@@ -1,20 +1,25 @@
#!/usr/bin/env python
import setuptools
"""Setup script for the 'uncompyle6' distribution."""
import sys
"""Setup script for the 'uncompyle6' distribution."""
import setuptools
SYS_VERSION = sys.version_info[0:2]
if not ((2, 4) <= SYS_VERSION < (3, 13)):
mess = "Python Release 2.6 .. 3.12 are supported in this code branch."
if not ((3, 3) <= SYS_VERSION < (3, 6)):
mess = "Python Release 3.3 .. 3.5 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 (3, 3) <= SYS_VERSION < (3, 6):
if SYS_VERSION >= (3, 6):
mess += (
"\nFor your Python, version %s, use the python-3.3-to-3.5 code/branch."
"\nFor your Python, version %s, use the master code/branch."
% sys.version[0:3]
)
if (3, 0) >= SYS_VERSION < (3, 3):
mess += (
"\nFor your Python, version %s, use the python-3.0-to-3.2 code/branch."
% sys.version[0:3]
)
elif SYS_VERSION < (2, 4):
@@ -25,17 +30,17 @@ if not ((2, 4) <= SYS_VERSION < (3, 13)):
raise Exception(mess)
from __pkginfo__ import (
__version__,
author,
author_email,
classifiers,
entry_points,
install_requires,
license,
long_description,
classifiers,
entry_points,
modname,
py_modules,
short_desc,
__version__,
web,
zip_safe,
)
@@ -55,7 +60,6 @@ setuptools.setup(
py_modules=py_modules,
test_suite="nose.collector",
url=web,
tests_require=["nose>=1.0"],
version=__version__,
zip_safe=zip_safe,
)

View File

@@ -115,7 +115,7 @@ check-bytecode-2:
# FIXME: Until we shaked out problems with xdis...
check-bytecode-3:
$(PYTHON) test_pythonlib.py \
--bytecode-3.4 --bytecode-3.5 --bytecode-3.6 \
--bytecode-3.3 --bytecode-3.4 --bytecode-3.5 --bytecode-3.6 \
--bytecode-3.7 --bytecode-3.8
#: Check deparsing on selected bytecode 3.x

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -29,6 +29,7 @@ storage.
#------------------------------------------------------------------------
import sys
absolute_import = (sys.version_info[0] >= 3)
if absolute_import :
# Because this syntaxis is not valid before Python 2.5
@@ -229,7 +230,7 @@ class DBShelf(MutableMapping):
def associate(self, secondaryDB, callback, flags=0):
def _shelf_callback(priKey, priData, realCallback=callback):
# Safe in Python 2.x because expresion short circuit
# Safe in Python 2.x because expression short circuit
if sys.version_info[0] < 3 or isinstance(priData, bytes) :
data = cPickle.loads(priData)
else :
@@ -366,7 +367,7 @@ class DBShelfCursor:
return None
else:
key, data = rec
# Safe in Python 2.x because expresion short circuit
# Safe in Python 2.x because expression short circuit
if sys.version_info[0] < 3 or isinstance(data, bytes) :
return key, cPickle.loads(data)
else :

View File

@@ -0,0 +1,18 @@
# 2.5 Bug is from nose/plugins/cover.py
def wantFile(self, file, package=None):
if self.coverInclusive:
if file.endswith(".py"):
if package and self.coverPackages:
for want in self.coverPackages:
if package.startswith(want):
return True
else:
return True
return None
# 2.5 bug is from nose/plugins/doctests.py
def wantFile2(self, file):
if self and (self.conf or [exc.search(file) for exc in self.conf]):
return True
return None

1
test/simple_source/bug26/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/.python-version

View File

@@ -3,10 +3,10 @@
# Grammar allows multiple adjacent 'if's in listcomps and genexps,
# even though it's silly. Make sure it works (ifelse broke this.)
[ x for x in range(10) if x % 2 if x % 3 ]
[x for x in range(10) if x % 2 if x % 3]
list(x for x in range(10) if x % 2 if x % 3)
# expresion which evaluates True unconditionally,
# expression which evaluates True unconditionally,
# but leave dead code or junk around that we have to match on.
# Tests "if_exp_true" rule
5 if 1 else 2

View File

@@ -0,0 +1,34 @@
# Bug portion of Issue #405 https://github.com/rocky/python-uncompyle6/issues/405
# Bug was detecting if/else as the last item in a "try: .. except" block.
class Saveframe(object):
"""A saveframe. Use the classmethod from_scratch to create one."""
frame_list = {}
def frame_dict(self):
return
# Next line is 1477
def __setitem__(self, key, item):
# Next line is 1481
if isinstance(item, Saveframe):
try:
self.frame_list[key] = item
except TypeError:
if key in (self.frame_dict()):
dict((frame.name, frame) for frame in self.frame_list)
for pos, frame in enumerate(self.frame_list):
if frame.name == key:
self.frame_list[pos] = item
else:
raise KeyError(
"Saveframe with name '%s' does not exist and "
"therefore cannot be written to. Use the add_saveframe method to add new saveframes."
% key
)
# Next line is 1498
raise ValueError("You can only assign an entry to a saveframe splice.")
x = Saveframe()
x.__setitem__("foo", 5)

View File

@@ -1,8 +1,8 @@
# From 2.7.17 test_bdb.py
# The problem was detecting a docstring at the begining of the module
# The problem was detecting a docstring at the beginning 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
# Note that this has to be compiled with optimization < 2 or else optimization
# will remove the docstring
"""Rational, infinite-precision, real numbers."""

View File

@@ -1,20 +1,20 @@
# Statements to beef up grammar coverage rules
# Force "inplace" ops
# Note this is like simple_source/bug22/01_ops.py
# But we don't ahve the UNARY_CONVERT which dropped
# But we don't have the UNARY_CONVERT which dropped
# out around 2.7
y = +10 # UNARY_POSITIVE
y /= 1 # INPLACE_DIVIDE
y %= 4 # INPLACE_MODULO
y /= 1 # INPLACE_DIVIDE
y %= 4 # INPLACE_MODULO
y **= 1 # INPLACE POWER
y >>= 2 # INPLACE_RSHIFT
y <<= 2 # INPLACE_LSHIFT
y //= 1 # INPLACE_TRUE_DIVIDE
y &= 1 # INPLACE_AND
y ^= 1 # INPLACE_XOR
y &= 1 # INPLACE_AND
y ^= 1 # INPLACE_XOR
# Beef up aug_assign and STORE_SLICE+3
x = [1,2,3,4,5]
x = [1, 2, 3, 4, 5]
x[0:1] = 1
x[0:3] += 1, 2, 3

View File

@@ -1,18 +1,20 @@
# From 3.x test_audiop.py
# Bug is handling default value after * argument in a lambda.
# That's a mouthful of desciption; I am not sure if the really
# That's a mouthful of description; I am not sure if the really
# hacky fix to the code is even correct.
#
# FIXME: try and test with more than one default argument.
# RUNNABLE
def pack(width, data):
return (width, data)
packs = {w: (lambda *data, width=w: pack(width, data)) for w in (1, 2, 4)}
assert packs[1]('a') == (1, ('a',))
assert packs[2]('b') == (2, ('b',))
assert packs[4]('c') == (4, ('c',))
assert packs[1]("a") == (1, ("a",))
assert packs[2]("b") == (2, ("b",))
assert packs[4]("c") == (4, ("c",))

View File

@@ -1,16 +1,19 @@
# From python 3.3.7 trace
# Bug was not having not having semantic rule for conditional not
# RUNNABLE!
def init(modules=None):
mods = set() if not modules else set(modules)
return mods
assert init() == set()
assert init([1, 2, 3]) == set([1, 2, 3])
# From 3.6 sre_parse
# Bug was in handling multple COME_FROMS from nested if's
# Bug was in handling multiple COME_FROMS from nested if's
def _escape(a, b, c, d, e):
if a:
if b:
@@ -24,15 +27,16 @@ def _escape(a, b, c, d, e):
return
raise
assert _escape(False, True, True, True, True) is None
assert _escape(True, True, True, False, True) is None
assert _escape(True, True, False, False, True) is None
assert _escape(False, True, True, True, True) is None
assert _escape(True, True, True, False, True) is None
assert _escape(True, True, False, False, True) is None
for args in (
(True, True, True, False, True),
(True, False, True, True, True),
(True, False, True, True, False),
):
(True, True, True, False, True),
(True, False, True, True, True),
(True, False, True, True, False),
):
try:
_escape(*args)
assert False, args

View File

@@ -0,0 +1,4 @@
# Next line is 1164
def foo():
name = "bar"
lambda x: compile(x, "<register %s's commit>" % name, "exec") if x else None

View File

@@ -0,0 +1,10 @@
# Adapted 3.5 from _bootstrap_external.py
def spec_from_file_location(loader, location):
if loader:
for _ in __file__:
if location:
break
else:
return None

View File

@@ -1,8 +1,9 @@
# From Python 3.4 asynchat.py
# Tests presence or absense of
# Tests presence or absence of
# SETUP_LOOP testexpr return_stmts POP_BLOCK COME_FROM_LOOP
# Note: that there is no JUMP_BACK because of the return_stmts.
def initiate_send(a, b, c, num_sent):
while a and b:
try:
@@ -24,6 +25,7 @@ def initiate_send2(a, b):
return 2
assert initiate_send(1, 1, 2, False) == 1
assert initiate_send(1, 2, 3, False) == 3
assert initiate_send(1, 2, 3, True) == 2

View File

@@ -1,13 +1,20 @@
# Python 3.6 changes, yet again, the way deafult pairs are handled
# Python 3.6 changes, yet again, the way default pairs are handled
def foo1(bar, baz=1):
return 1
def foo2(bar, baz, qux=1):
return 2
def foo3(bar, baz=1, qux=2):
return 3
def foo4(bar, baz, qux=1, quux=2):
return 4
# From 3.6 compileall.
# Bug was in omitting default which when used in an "if"
# are treated as False would be

View File

@@ -1,17 +1,23 @@
# From 3.6 test_abc.py
# Bug was Reciever() class definition
# Bug was Receiver() class definition
import abc
import unittest
class TestABCWithInitSubclass(unittest.TestCase):
def test_works_with_init_subclass(self):
class ReceivesClassKwargs:
def __init_subclass__(cls, **kwargs):
super().__init_subclass__()
class Receiver(ReceivesClassKwargs, abc.ABC, x=1, y=2, z=3):
pass
def test_abstractmethod_integration(self):
for abstractthing in [abc.abstractmethod]:
class C(metaclass=abc.ABCMeta):
@abstractthing
def foo(self): pass # abstract
def foo(self):
pass # abstract

View File

@@ -1,12 +1,12 @@
# From 3.6 base64.py
# Bug was handling "and" condition in the presense of POP_JUMP_IF_FALSE
# Bug was handling "and" condition in the presence of POP_JUMP_IF_FALSE
# locations
def _85encode(foldnuls, words):
return ['z' if foldnuls and word
else 'y'
for word in words]
return ["z" if foldnuls and word else "y" for word in words]
# From Python 3.6 enum.py
def __new__(metacls, cls, bases, classdict):
{k: classdict[k] for k in classdict._member_names}

View File

@@ -0,0 +1,74 @@
# From https://github.com/rocky/python-uncompyle6/issues/420
# Related to EXTENDED_ARG in whilestmt
ERRPR_CODE_DEFINE = {} # Remove this and things works
try:
print()
except Exception:
var1 = 0
var2 = 1
if var1 or var2:
times = 1
while times != False and self.scanner.is_open():
try:
try:
print()
except Exception:
print()
out = 0
count = 1
if out == 1:
break
elif out == 2:
count += 1
if times == 3:
self.func.emit({})
break
else:
continue
if out == 3 or out == b"":
if self.times == 3:
break
count += 1
if count == 3:
count = 0
if out == 4:
self.func.emit(ERRPR_CODE_DEFINE.ReceiedError())
else:
print()
break
continue
else:
count = 0
except Exception:
print("upper exception")
else:
try:
print("jump forward")
while True:
out = self.func.read(count)
if out == b"":
self.func.emit(ERRPR_CODE_DEFINE.ReceiedError())
break
continue
imagedata = out[0]
if imagedata == b"\x05":
self.func.emit(INFORMATION.UnsupportedImage())
break
continue
if imagedata == b"\x15":
self.func.emit(INFORMATION.NoneImage())
break
continue
if out[1] == False:
start_index = imagedata.find(b"BM6")
self.func.emit(imagedata[start_index:], False)
continue
(imagedata, all_code) = imagedata
self.func.emit({})
self.func.emit({})
self.func.emit({}) # remove {} and this works
break
except Exception:
pass

View File

@@ -14,6 +14,7 @@ assert (
assert "def0" == f"{abc}0"
assert "defdef" == f"{abc}{abc!s}"
# From 3.8 test/test_string.py
# We had the precedence of yield vs. lambda incorrect.
def fn(x):
@@ -97,9 +98,10 @@ else:
(x, y, width) = ("foo", 2, 10)
assert f"x={x*y:{width}}" == "x=foofoo "
# Why the fact that the distinction of docstring versus stmt is a
# string expression is important academic, but we will decompile an
# equivalent thing. For compatiblity with older Python we'll use "%"
# equivalent thing. For compatibility with older Python we'll use "%"
# instead of a format string
def f():
f"""Not a docstring""" # noqa

View File

@@ -1,26 +1,27 @@
# From 3.6 _markupbase.py
# Bug is that the routine is long enough that POP_JUMP_IF_FALSE instruciton has an
# EXTENDED_ARG intruction before it and we weren't picking out the jump offset properly
# Bug is that the routine is long enough that POP_JUMP_IF_FALSE instruction has an
# EXTENDED_ARG instruction before it and we weren't picking out the jump offset properly
def parse_declaration(self, i):
if rawdata[j:j] in ("-", ""):
return -1
n = len(rawdata)
if rawdata[j:j+2] == '-':
if rawdata[j : j + 2] == "-":
return self.parse_comment(i)
elif rawdata[j] == '[':
elif rawdata[j] == "[":
return self.parse_marked_section(i)
else:
decltype, j = self._scan_name(j, i)
if j < 0:
return j
if decltype == "d":
self._decl_otherchars = ''
self._decl_otherchars = ""
while j < n:
c = rawdata[j]
if c == ">":
data = rawdata[i+2:j]
data = rawdata[i + 2 : j]
if decltype == "d":
self.handle_decl(data)
else:
@@ -43,8 +44,7 @@ def parse_declaration(self, i):
else:
self.error("unexpected '[' char in declaration")
else:
self.error(
"unexpected %r char in declaration" % rawdata[j])
self.error("unexpected %r char in declaration" % rawdata[j])
if j < 0:
return j
return -1

View File

@@ -0,0 +1,9 @@
# See https://github.com/rocky/python-uncompyle6/issues/498
# Bug was in not allowing _stmts in whilestmt38
import time
r = 0
while r == 1:
print(time.time())
if r == 1:
r = 0

View File

@@ -1,5 +1,5 @@
# Tests custom added grammar rule:
# expr ::= expr {expr}^n CALL_FUNCTION_n
# which in the specifc case below is:
# which in the specific case below is:
# expr ::= expr expr expr CALL_FUNCTION_2
max(1, 2)

View File

@@ -27,7 +27,7 @@ while 1:
else:
raise RuntimeError
# Degenerate case. Note: we can't run becase this causes an infinite loop.
# Degenerate case. Note: we can't run because this causes an infinite loop.
# Suggested in issue #172
while 1:
pass

View File

@@ -1,7 +1,8 @@
# From 3.6.10 test_binascii.py
# Bug was getting "while c and noise" parsed correclty
# Bug was getting "while c and noise" parsed correctly
# and not put into the "ifelsesmt"
# RUNNABLE!
def addnoise(c, noise):
while c and noise:
@@ -12,6 +13,7 @@ def addnoise(c, noise):
noise = False
return c
assert addnoise(0, True) == 0
assert addnoise(1, False) == 1
assert addnoise(2, True) == 2
@@ -19,9 +21,10 @@ assert addnoise(3, True) == 3
assert addnoise(4, True) == 3
assert addnoise(5, False) == 5
# From 3.6.10 test_dbm_dumb.py
# Bug was getting attaching "else" to the right "if" in the
# presense of a loop.
# presence of a loop.
def test_random(a, r):
x = 0
for dummy in r:
@@ -32,11 +35,13 @@ def test_random(a, r):
x += 1
return x
assert test_random(True, [1]) == 2
assert test_random(True, [1, 1]) == 4
assert test_random(False, [1]) == 0
assert test_random(False, [1, 1]) == 0
# From 2.7.17 test_frozen.py
# Bug was getting making sure we have "try" not
# "try"/"else"
@@ -53,11 +58,13 @@ def test_frozen(a, b):
return x
assert test_frozen(1, 1) == 4.0
assert test_frozen(0, 1) == 5.0
assert test_frozen(0.5, 0) == 6.0
assert test_frozen(0, 0.5) == 8.0
# From 3.6.10 test_binop.py
# Bug was getting "other += 3" outside of "if"/"else.
def __floordiv__(a, b):
@@ -70,6 +77,7 @@ def __floordiv__(a, b):
other += 3
return other
assert __floordiv__(True, True) == 4
assert __floordiv__(True, False) == 4
assert __floordiv__(False, True) == 3

View File

@@ -1,19 +1,19 @@
# Self-checking test.
# Mixed boolean expresions
# Mixed boolean expressions
b = True
assert b, 'b = True'
assert b, "b = True"
c = False
assert not c, 'c = False'
assert not c, "c = False"
d = True
a = b and c or d
assert a, 'b and c or d'
assert a, "b and c or d"
a = (b or c) and d
assert a, '(b or c) and d'
assert a, "(b or c) and d"
a = b or c or d
assert a, 'b or c or d'
assert a, "b or c or d"
a = b and c and d
assert not a, 'b and c and d'
assert not a, "b and c and d"
a = b or c and d
assert a
a = b and (c or d)

View File

@@ -1,5 +1,5 @@
# 2.6.9 symbols.py
# Bug in 2.6 is having multple COME_FROMs due to the
# Bug in 2.6 is having multiple COME_FROMs due to the
# "and" in the "if" clause
# RUNNABLE
@@ -10,7 +10,7 @@ if __name__:
assert False
# 2.6.9 transformer.py
# Bug in 2.6 is multple COME_FROMs as a result
# Bug in 2.6 is multiple COME_FROMs as a result
# of the "or" in the "assert"
# In PyPy the assert is handled via PyPy's unique JUMP_IF_NOT_DEBUG
@@ -24,6 +24,7 @@ elif __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
@@ -36,6 +37,7 @@ def __floordiv__(a, b):
b += 5
return b
assert __floordiv__(1, 1) == 7
assert __floordiv__(1, 0) == 6
assert __floordiv__(0, 3) == 8

View File

@@ -0,0 +1,21 @@
"""
This program is self checking!
"""
class TestContextManager:
def __enter__(self):
return 1, 2
def __exit__(self, exc_type, exc_value, exc_tb):
return self, exc_type, exc_value, exc_tb
with open(__file__) as a:
assert a
with open(__file__) as a, open(__file__) as b:
assert a.read() == b.read()
with TestContextManager() as a, b:
assert (a, b) == (1, 2)

View File

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

View File

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

View File

@@ -38,17 +38,14 @@ SKIP_TESTS=(
[test_winreg.py]=1 # it fails on its own
[test_winsound.py]=1 # it fails on its own
[test_zlib.py]=1 # it fails on its own
[test_decimal.py]=1 #
[test_decimal.py]=1 # fails on its own - no module named test_support
[test_dis.py]=1 # We change line numbers - duh!
[test_generators.py]=1 # Investigate
[test_generators.py]=1 # fails on its own - no module named test_support
# [test_grammar.py]=1 # fails on its own - no module tests.test_support
[test_grp.py]=1 # Long test - might work Control flow?
[test_pep247.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
[test_trace.py]=1 # Long test - works
[test_zipfile64.py]=1 # Runs ok but takes 204 seconds
)
# About 243 files, 0 in 19 minutes

View File

@@ -10,7 +10,7 @@ SKIP_TESTS=(
# tgt.append(elem)
[test_itertools.py]=1
[test_buffer.py]=pytest # FIXME: Works on c90ff51
[test_buffer.py]=pytest
[test_cmath.py]=pytest
[test_atexit.py]=1 # The atexit test starting at 3.3 looks for specific comments in error lines
@@ -19,7 +19,6 @@ SKIP_TESTS=(
[test_concurrent_futures.py]=1 # too long?
[test_decimal.py]=1 # test takes too long to run: 18 seconds
[test_descr.py]=1 # test assertion errors
[test_doctest.py]=1 # test assertion errors
[test_doctest2.py]=1 # test assertion errors
[test_dis.py]=1 # We change line numbers - duh!

View File

@@ -26,7 +26,16 @@ SKIP_TESTS=(
[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
# ERROR: test_reent_set_bases_on_base (__main__.MroTest)
# Traceback (most recent call last):
# File "test_descr.py", line 5521, in test_reent_set_bases_on_base
# class A(metaclass=M):
# File "test_descr.py", line 5472, in __new__
# return type.__new__(mcls, name, bases, attrs)
# TypeError: 'NoneType' object is not iterable
[test_dis.py]=1 # We change line numbers - duh!
[test_distutils.py]=1 # it fails on its own
[test_doctest2.py]=1

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
# emacs-mode: -*-python-*-
"""
test_pyenvlib -- uncompyle and verify Python libraries
test_pyenvlib -- decompile and verify Python libraries
Usage-Examples:
@@ -20,14 +20,19 @@ Step 2: Run the test:
test_pyenvlib --mylib --verify # decompile verify 'mylib'
"""
from __future__ import print_function
import os, time, re, shutil, sys
# Does not work on 2.5.9 or before
# from __future__ import print_function
import os
import re
import shutil
import sys
import time
from fnmatch import fnmatch
from uncompyle6 import main
import xdis.magics as magics
from uncompyle6 import main
# ----- configure this for your needs
python_versions = [v for v in magics.python_versions if re.match("^[0-9.]+$", v)]
@@ -82,9 +87,10 @@ for vers in TEST_VERSIONS:
if vers == "native":
short_vers = os.path.basename(sys.path[-1])
from xdis.version_info import PYTHON_VERSION_TRIPLE, version_tuple_to_str
if PYTHON_VERSION_TRIPLE > (3, 0):
version = version_tuple_to_str(end=2)
PYC = f"*.cpython-{version}.pyc"
PYC = "*.cpython-%s.pyc" % version
test_options[vers] = (sys.path[-1], PYC, short_vers)
else:
short_vers = vers[:3]
@@ -133,8 +139,17 @@ def do_tests(
pass
if len(files) > max_files:
files = [file for file in files if not "site-packages" in file and (file.endswith(".pyo") or file.endswith(".pyc"))]
files = [file for file in files if not "test" in file and (file.endswith(".pyo") or file.endswith(".pyc"))]
files = [
file
for file in files
if not "site-packages" in file
and (file.endswith(".pyo") or file.endswith(".pyc"))
]
files = [
file
for file in files
if not "test" in file and (file.endswith(".pyo") or file.endswith(".pyc"))
]
if len(files) > max_files:
# print("Number of files %d - truncating to last 200" % len(files))
print(
@@ -151,7 +166,8 @@ def do_tests(
if __name__ == "__main__":
import getopt, sys
import getopt
import sys
do_coverage = do_verify = False
test_dirs = []

View File

@@ -64,8 +64,9 @@ PATTERNS = ("*.pyc", "*.pyo")
def main():
usage_short = (
f"""usage: {program} FILE...
"""usage: %s FILE...
Type -h for for full help."""
% program
)
if len(sys.argv) == 1:
@@ -78,7 +79,7 @@ Type -h for for full help."""
sys.argv[1:], "hVU", ["help", "version", "uncompyle6"]
)
except getopt.GetoptError as e:
print(f"{os.path.basename(sys.argv[0])}: {e}", file=sys.stderr)
print("%s: %s" % (os.path.basename(sys.argv[0]), e), file=sys.stderr)
sys.exit(-1)
for opt, val in opts:
@@ -86,7 +87,7 @@ Type -h for for full help."""
print(__doc__)
sys.exit(1)
elif opt in ("-V", "--version"):
print(f"{program} {__version__}")
print("%s %s" % (program, __version__))
sys.exit(0)
else:
print(opt)
@@ -97,7 +98,7 @@ Type -h for for full help."""
if os.path.exists(files[0]):
disassemble_file(file, sys.stdout)
else:
print(f"Can't read {files[0]} - skipping", file=sys.stderr)
print("Can't read %s - skipping" % files[0], file=sys.stderr)
pass
pass
return

View File

@@ -5,12 +5,10 @@
# by Rocky Bernstein
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
#
from __future__ import print_function
import os
import sys
import time
from typing import List
import click
from xdis.version_info import version_tuple_to_str
@@ -30,7 +28,7 @@ def usage():
# __doc__ = """
# Usage:
# %s [OPTIONS]... [ FILE | DIR]...
# %s [--help | -h | --V | --version]
# %s [--help | --version]
# Examples:
# %s foo.pyc bar.pyc # decompile foo.pyc, bar.pyc to stdout
@@ -159,19 +157,27 @@ def main_bin(
"""
version_tuple = sys.version_info[0:2]
if version_tuple < (3, 6):
print(
f"Error: This version of the {program} runs from Python 3.6 or greater."
f"You need another branch of this code for Python before 3.6."
f""" \n\tYou have version: {version_tuple_to_str()}."""
)
sys.exit(-1)
if not ((3, 3) <= version_tuple < (3, 6)):
if version_tuple > (3, 5):
print(
"This version of the {program} is tailored for Python 3.3 to 3.5.\n"
"It may run on other versions, but there are problems, switch to code "
"from another branch.\n"
"You have version: %s." % version_tuple_to_str()
)
else:
print(
"Error: This version of the {program} runs from Python 3.3 to 3.5.\n"
"You need another branch of this code for other Python versions."
" \n\tYou have version: %s." % version_tuple_to_str()
)
sys.exit(-1)
numproc = 0
out_base = None
out_base = None
source_paths: List[str] = []
source_paths = []
timestamp = False
timestampfmt = "# %Y.%m.%d %H:%M:%S %Z"
pyc_paths = files

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2015-2016, 2818-2022 by Rocky Bernstein
# Copyright (c) 2015-2016, 2818-2022, 2024 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
@@ -17,10 +17,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
CPython magic- and version- independent disassembly routines
CPython magic- and version-independent disassembly routines
There are two reasons we can't use Python's built-in routines
from dis. First, the bytecode we are extracting may be from a different
from ``dis``.
First, the bytecode we are extracting may be from a different
version of Python (different magic number) than the version of Python
that is doing the extraction.
@@ -39,12 +41,12 @@ from uncompyle6.scanner import get_scanner
def disco(version, co, out=None, is_pypy=False):
"""
diassembles and deparses a given code block 'co'
diassembles and deparses a given code block ``co``.
"""
assert iscode(co)
# store final output stream for case of error
# Store final output stream in case there is an error.
real_out = out or sys.stdout
print("# Python %s" % version_tuple_to_str(version), file=real_out)
if co.co_filename:
@@ -99,7 +101,7 @@ def disco_loop(disasm, queue, real_out):
def disassemble_file(filename, outstream=None):
"""
disassemble Python byte-code file (.pyc)
Disassemble Python byte-code file (.pyc).
If given a Python source file (".py") file, we'll
try to find the corresponding compiled object.
@@ -113,7 +115,6 @@ def disassemble_file(filename, outstream=None):
disco(version, con, outstream)
else:
disco(version, co, outstream, is_pypy=is_pypy)
co = None
def _test():

View File

@@ -21,7 +21,6 @@ import py_compile
import subprocess
import sys
import tempfile
from typing import Any, Optional, TextIO, Tuple
from xdis import iscode
from xdis.load import load_module
@@ -38,7 +37,7 @@ from uncompyle6.version import __version__
# from uncompyle6.linenumbers import line_number_mapping
def _get_outstream(outfile: str) -> Any:
def _get_outstream(outfile):
"""
Return an opened output file descriptor for ``outfile``.
"""
@@ -66,9 +65,9 @@ def syntax_check(filename: str) -> bool:
def decompile(
co,
bytecode_version: Tuple[int] = PYTHON_VERSION_TRIPLE,
out: Optional[TextIO] = sys.stdout,
showasm: Optional[str] = None,
bytecode_version=PYTHON_VERSION_TRIPLE,
out=sys.stdout,
showasm=None,
showast={},
timestamp=None,
showgrammar=False,
@@ -82,7 +81,7 @@ def decompile(
compile_mode="exec",
start_offset: int = 0,
stop_offset: int = -1,
) -> Any:
):
"""
ingests and deparses a given code block 'co'
@@ -101,13 +100,13 @@ def decompile(
s += "\n"
real_out.write(s)
assert iscode(co), f"""{co} does not smell like code"""
assert iscode(co), "%s does not smell like code" % co
co_pypy_str = "PyPy " if is_pypy else ""
run_pypy_str = "PyPy " if IS_PYPY else ""
sys_version_lines = sys.version.split("\n")
if source_encoding:
write(f"# -*- coding: {source_encoding} -*-")
write("# -*- coding: %s -*-" % source_encoding)
write(
"# uncompyle6 version %s\n"
"# %sPython bytecode version base %s%s\n# Decompiled from: %sPython %s"
@@ -121,9 +120,9 @@ def decompile(
)
)
if co.co_filename:
write(f"# Embedded file name: {co.co_filename}")
write("# Embedded file name: %s" % co.co_filename)
if timestamp:
write(f"# Compiled at: {datetime.datetime.fromtimestamp(timestamp)}")
write("# Compiled at: %s" % datetime.datetime.fromtimestamp(timestamp))
if source_size:
write("# Size of source mod 2**32: %d bytes" % source_size)
@@ -154,7 +153,7 @@ def decompile(
(line_no, deparsed.source_linemap[line_no] + header_count)
for line_no in sorted(deparsed.source_linemap.keys())
]
mapstream.write(f"\n\n# {linemap}\n")
mapstream.write("\n\n# %s\n" % linemap)
else:
if do_fragments:
deparse_fn = code_deparse_fragments
@@ -178,26 +177,26 @@ def decompile(
raise pysource.SourceWalkerError(str(e))
def compile_file(source_path: str) -> str:
def compile_file(source_path):
if source_path.endswith(".py"):
basename = source_path[:-3]
else:
basename = source_path
if hasattr(sys, "pypy_version_info"):
bytecode_path = f"{basename}-pypy{version_tuple_to_str()}.pyc"
bytecode_path = "%s-pypy%s.pyc" % (basename, version_tuple_to_str())
else:
bytecode_path = f"{basename}-{version_tuple_to_str()}.pyc"
bytecode_path = "%s-%s.pyc" % (basename, version_tuple_to_str())
print(f"compiling {source_path} to {bytecode_path}")
print("compiling %s to %s" % (source_path, bytecode_path))
py_compile.compile(source_path, bytecode_path, "exec")
return bytecode_path
def decompile_file(
filename: str,
outstream: Optional[TextIO] = None,
showasm: Optional[str] = None,
outstream=None,
showasm=None,
showast={},
showgrammar=False,
source_encoding=None,
@@ -205,7 +204,7 @@ def decompile_file(
do_fragments=False,
start_offset=0,
stop_offset=-1,
) -> Any:
):
"""
decompile Python byte-code file (.pyc). Return objects to
all of the deparsed objects found in `filename`.
@@ -266,20 +265,20 @@ def decompile_file(
# FIXME: combine into an options parameter
def main(
in_base: str,
out_base: Optional[str],
out_base,
compiled_files: list,
source_files: list,
outfile: Optional[str] = None,
showasm: Optional[str] = None,
outfile=None,
showasm=None,
showast={},
do_verify: Optional[str] = None,
do_verify=None,
showgrammar: bool = False,
source_encoding=None,
do_linemaps=False,
do_fragments=False,
start_offset: int = 0,
stop_offset: int = -1,
) -> Tuple[int, int, int, int]:
):
"""
in_base base directory for input files
out_base base directory for output files (ignored when
@@ -303,7 +302,7 @@ def main(
infile = osp.join(in_base, filename)
# print("XXX", infile)
if not osp.exists(infile):
sys.stderr.write(f"File '{infile}' doesn't exist. Skipped\n")
sys.stderr.write("File '%s' doesn't exist. Skipped\n" % infile)
continue
if do_linemaps:
@@ -358,11 +357,11 @@ def main(
):
if e[0] != last_mod:
line = "=" * len(e[0])
outstream.write(f"{line}\n{e[0]}\n{line}\n")
outstream.write("%s\n%s\n%s\n" % (line, e[0], line))
last_mod = e[0]
info = offsets[e]
extract_info = deparse_object.extract_node_info(info)
outstream.write(f"{info.node.format().strip()}" + "\n")
extract_info = deparsed_object.extract_node_info(info)
outstream.write("%s" % info.node.format().strip() + "\n")
outstream.write(extract_info.selectedLine + "\n")
outstream.write(extract_info.markerLine + "\n\n")
pass
@@ -372,49 +371,41 @@ def main(
deparsed_object.f.close()
if PYTHON_VERSION_TRIPLE[:2] != deparsed_object.version[:2]:
sys.stdout.write(
f"\n# skipping running {deparsed_object.f.name}; it is"
f"{version_tuple_to_str(deparsed_object.version, end=2)}, "
"and we are "
f"{version_tuple_to_str(PYTHON_VERSION_TRIPLE, end=2)}\n"
"\n# skipping running %s; it is %s and we are %s"
% (
deparsed_object.f.name,
version_tuple_to_str(deparsed_object.version, end=2),
version_tuple_to_str(PYTHON_VERSION_TRIPLE, end=2),
)
)
else:
check_type = "syntax check"
if do_verify == "run":
check_type = "run"
if PYTHON_VERSION_TRIPLE >= (3, 7):
result = subprocess.run(
[sys.executable, deparsed_object.f.name],
capture_output=True,
)
valid = result.returncode == 0
output = result.stdout.decode()
if output:
print(output)
pass
else:
result = subprocess.run(
[sys.executable, deparsed_object.f.name],
)
valid = result.returncode == 0
pass
return_code = subprocess.call(
[sys.executable, deparsed_object.f.name],
stdout=sys.stdout,
stderr=sys.stderr,
)
valid = return_code == 0
if not valid:
print(result.stderr.decode())
sys.stderr.write("Got return code %d\n" % return_code)
else:
valid = syntax_check(deparsed_object.f.name)
if not valid:
verify_failed_files += 1
sys.stderr.write(
f"\n# {check_type} failed on file {deparsed_object.f.name}\n"
"\n# %s failed on file %s\n"
% (check_type, deparsed_object.f.name)
)
# sys.stderr.write(f"Ran {deparsed_object.f.name}\n")
# sys.stderr.write("Ran %\n" % deparsed_object.f.name)
pass
tot_files += 1
except (ValueError, SyntaxError, ParserError, pysource.SourceWalkerError) as e:
sys.stdout.write("\n")
sys.stderr.write(f"\n# file {infile}\n# {e}\n")
sys.stderr.write("\n# file %s\n# %s\n" % (infile, e))
failed_files += 1
tot_files += 1
except KeyboardInterrupt:
@@ -422,19 +413,21 @@ def main(
outstream.close()
os.remove(outfile)
sys.stdout.write("\n")
sys.stderr.write(f"\nLast file: {infile} ")
sys.stderr.write("\nLast file: %s " % (infile))
raise
except RuntimeError as e:
sys.stdout.write(f"\n{str(e)}\n")
sys.stdout.write("\n%s\n" % str(e))
if str(e).startswith("Unsupported Python"):
sys.stdout.write("\n")
sys.stderr.write(f"\n# Unsupported bytecode in file {infile}\n# {e}\n")
sys.stderr.write(
"\n# Unsupported bytecode in file %s\n# %s\n" % (infile, e)
)
else:
if outfile:
outstream.close()
os.remove(outfile)
sys.stdout.write("\n")
sys.stderr.write(f"\nLast file: {infile} ")
sys.stderr.write("\nLast file: %s " % (infile))
raise
# except:
@@ -511,5 +504,9 @@ def status_msg(tot_files, okay_files, failed_files, verify_failed_files):
return "\n# Successfully decompiled file"
pass
pass
mess = f"decompiled {tot_files} files: {okay_files} okay, {failed_files} failed"
mess = "decompiled %i files: %i okay, %i failed" % (
tot_files,
okay_files,
failed_files,
)
return mess

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2015-2023 Rocky Bernstein
# Copyright (c) 2015-2024 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
@@ -21,10 +21,11 @@ Common uncompyle6 parser routines.
import sys
from spark_parser import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
from uncompyle6.show import maybe_show_asm
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG, GenericASTBuilder
from xdis import iscode
from uncompyle6.show import maybe_show_asm
class ParserError(Exception):
def __init__(self, token, offset, debug=PARSER_DEFAULT_DEBUG):
@@ -91,7 +92,14 @@ class PythonParser(GenericASTBuilder):
# singleton reduction that we can simplify. It also happens to be optional
# in its other derivation
self.optional_nt |= frozenset(
("come_froms", "suite_stmts", "l_stmts_opt", "c_stmts_opt", "stmts_opt", "stmt")
(
"come_froms",
"suite_stmts",
"l_stmts_opt",
"c_stmts_opt",
"stmts_opt",
"stmt",
)
)
# Reduce singleton reductions in these nonterminals:
@@ -113,10 +121,10 @@ class PythonParser(GenericASTBuilder):
def add_unique_rule(self, rule, opname, arg_count, customize):
"""Add rule to grammar, but only if it hasn't been added previously
opname and stack_count are used in the customize() semantic
the actions to add the semantic action rule. Stack_count is
used in custom opcodes like MAKE_FUNCTION to indicate how
many arguments it has. Often it is not used.
opname and stack_count are used in the customize() semantic
the actions to add the semantic action rule. Stack_count is
used in custom opcodes like MAKE_FUNCTION to indicate how
many arguments it has. Often it is not used.
"""
if rule not in self.new_rules:
# print("XXX ", rule) # debug
@@ -223,7 +231,9 @@ class PythonParser(GenericASTBuilder):
"""
# Low byte indicates number of positional parameters,
# high byte number of keyword parameters
assert token.kind.startswith("CALL_FUNCTION") or token.kind.startswith("CALL_METHOD")
assert token.kind.startswith("CALL_FUNCTION") or token.kind.startswith(
"CALL_METHOD"
)
args_pos = token.attr & 0xFF
args_kw = (token.attr >> 8) & 0xFF
return args_pos, args_kw
@@ -364,7 +374,7 @@ class PythonParser(GenericASTBuilder):
stmt ::= tryelsestmt
stmt ::= tryfinallystmt
stmt ::= with
stmt ::= withasstmt
stmt ::= with_as
stmt ::= delete
delete ::= DELETE_FAST
@@ -381,6 +391,10 @@ class PythonParser(GenericASTBuilder):
returns ::= return
returns ::= _stmts return
# NOP
stmt ::= nop_stmt
nop_stmt ::= NOP
"""
pass
@@ -659,6 +673,8 @@ def get_python_parser(
version = version[:2]
p = None
# FIXME: there has to be a better way...
# We could do this as a table lookup, but that would force us
# in import all of the parsers all of the time. Perhaps there is
@@ -907,7 +923,7 @@ def python_parser(
if __name__ == "__main__":
def parse_test(co):
from xdis import PYTHON_VERSION_TRIPLE, IS_PYPY
from xdis import IS_PYPY, PYTHON_VERSION_TRIPLE
ast = python_parser(PYTHON_VERSION_TRIPLE, co, showasm=True, is_pypy=IS_PYPY)
print(ast)

View File

@@ -64,7 +64,7 @@ class Python14Parser(Python15Parser):
if opname_base == "UNPACK_VARARG":
if token.attr > 1:
self.addRule(f"star_args ::= RESERVE_FAST {opname} args_store", nop_func)
self.addRule("star_args ::= RESERVE_FAST %s args_store" % opname, nop_func)
def reduce_is_invalid(self, rule, ast, tokens, first, last):

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2016-2018, 2020, 2022-2023 Rocky Bernstein
# Copyright (c) 2016-2018, 2020, 2022-2024 Rocky Bernstein
"""
spark grammar differences over Python2.5 for Python 2.4.
"""
@@ -89,12 +89,14 @@ class Python24Parser(Python25Parser):
while1stmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK COME_FROM
while1stmt ::= SETUP_LOOP returns COME_FROM
whilestmt ::= SETUP_LOOP testexpr returns POP_BLOCK COME_FROM
with ::= expr setupwith SETUP_FINALLY suite_stmts_opt POP_BLOCK
LOAD_CONST COME_FROM with_cleanup
with_as ::= expr setupwithas store suite_stmts_opt POP_BLOCK
LOAD_CONST COME_FROM with_cleanup
with_cleanup ::= LOAD_FAST DELETE_FAST WITH_CLEANUP END_FINALLY
with_cleanup ::= LOAD_NAME DELETE_NAME WITH_CLEANUP END_FINALLY
withasstmt ::= expr setupwithas store suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM with_cleanup
with ::= expr setupwith SETUP_FINALLY suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM with_cleanup
stmt ::= with
stmt ::= withasstmt
stmt ::= with
stmt ::= with_as
"""
)
super(Python24Parser, self).customize_grammar_rules(tokens, customize)
@@ -118,19 +120,6 @@ class Python24Parser(Python25Parser):
token_len = len(tokens)
if 0 <= token_len < len(tokens):
return not int(tokens[first].pattr) == tokens[last].offset
elif lhs == "try_except":
if last == len(tokens):
last -= 1
if tokens[last] != "COME_FROM" and tokens[last - 1] == "COME_FROM":
last -= 1
return (
tokens[last] == "COME_FROM"
and tokens[last - 1] == "END_FINALLY"
and tokens[last - 2] == "POP_TOP"
and tokens[last - 3].kind != "JUMP_FORWARD"
)
return False
class Python24ParserSingle(Python24Parser, PythonParserSingle):

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2016-2018, 2020, 2022 Rocky Bernstein
# Copyright (c) 2016-2018, 2020, 2022, 2024 Rocky Bernstein
"""
spark grammar differences over Python2.6 for Python 2.5.
"""
@@ -33,9 +33,11 @@ class Python25Parser(Python26Parser):
POP_BLOCK LOAD_CONST COME_FROM with_cleanup
# Semantic actions want store to be at index 2
withasstmt ::= expr setupwithas store suite_stmts_opt
with_as ::= expr setupwithas store suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM with_cleanup
# The last except of a "try: ... except" can do this...
except_suite ::= c_stmts_opt COME_FROM JUMP_ABSOLUTE POP_TOP
store ::= STORE_NAME
store ::= STORE_FAST
@@ -48,7 +50,7 @@ class Python25Parser(Python26Parser):
# Python 2.6 omits the LOAD_FAST DELETE_FAST below
# withas is allowed as a "from future" in 2.5
withasstmt ::= expr setupwithas store suite_stmts_opt
with_as ::= expr setupwithas store suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM
with_cleanup
@@ -58,6 +60,13 @@ class Python25Parser(Python26Parser):
kvlist ::= kvlist kv
kv ::= DUP_TOP expr ROT_TWO expr STORE_SUBSCR
_ifstmts_jump ::= c_stmts_opt COME_FROM JUMP_ABSOLUTE COME_FROM POP_TOP
# "and_then" is a hack around the fact we have THEN detection.
and_then ::= expr JUMP_IF_FALSE THEN POP_TOP expr JUMP_IF_FALSE THEN POP_TOP
testexpr_then ::= and_then
"""
def customize_grammar_rules(self, tokens, customize):
@@ -67,7 +76,7 @@ class Python25Parser(Python26Parser):
setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP
with ::= expr setupwith SETUP_FINALLY suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
withasstmt ::= expr setupwithas store suite_stmts_opt
with_as ::= expr setupwithas store suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr CALL_FUNCTION_1 RAISE_VARARGS_1
classdefdeco ::= classdefdeco1 store

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2017-2023 Rocky Bernstein
# Copyright (c) 2017-2024 Rocky Bernstein
"""
spark grammar differences over Python2 for Python 2.6.
"""
@@ -130,13 +130,20 @@ class Python26Parser(Python2Parser):
# Semantic actions want else_suitel to be at index 3
ifelsestmtl ::= testexpr c_stmts_opt cf_jb_cf_pop else_suitel
ifelsestmtc ::= testexpr c_stmts_opt ja_cf_pop else_suitec
ifelsestmt ::= testexpr stmts_opt ja_cf_pop else_suite
stmts_opt ::= stmts
stmts_opt ::=
# The last except of a "try: ... except" can do this...
except_suite ::= stmts_opt COME_FROM JUMP_ABSOLUTE POP_TOP
# Semantic actions want suite_stmts_opt to be at index 3
with ::= expr setupwith SETUP_FINALLY suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
# Semantic actions want store to be at index 2
withasstmt ::= expr setupwithas store suite_stmts_opt
with_as ::= expr setupwithas store suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
# This is truly weird. 2.7 does this (not including POP_TOP) with
@@ -352,9 +359,9 @@ class Python26Parser(Python2Parser):
def customize_grammar_rules(self, tokens, customize):
self.remove_rules(
"""
withasstmt ::= expr SETUP_WITH store suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_WITH
WITH_CLEANUP END_FINALLY
with_as ::= expr SETUP_WITH store suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_WITH
WITH_CLEANUP END_FINALLY
"""
)
super(Python26Parser, self).customize_grammar_rules(tokens, customize)
@@ -391,7 +398,6 @@ class Python26Parser(Python2Parser):
("and", ("expr", "jmp_false", "expr", "come_from_opt")),
("assert_expr_and", ("assert_expr", "jmp_false", "expr")),
):
# FIXME: workaround profiling bug
if ast[1] is None:
return False
@@ -467,14 +473,16 @@ class Python26Parser(Python2Parser):
return tokens[last].offset != ja_attr
elif lhs == "try_except":
# We need to distinguish "try_except" from "tryelsestmt"; we do that
# by checking the jump before the END_FINALLY
# by looking for a jump before the END_FINALLY to the "else" clause of
# "try else".
#
# If we have:
# insn
# <insn>
# POP_TOP
# END_FINALLY
# COME_FROM
# then insn has to be either a JUMP_FORWARD or a RETURN_VALUE
# and if it is JUMP_FORWARD, then it has to be a JUMP_FORWARD to right after
# then <insn> has to be either a a jump of some sort (JUMP_FORWARD, BREAK_LOOP, JUMP_BACK, or RETURN_VALUE).
# Furthermore, if it is JUMP_FORWARD, then it has to be a JUMP_FORWARD to right after
# COME_FROM
if last == len(tokens):
last -= 1
@@ -488,54 +496,8 @@ class Python26Parser(Python2Parser):
# A jump of 2 is a jump around POP_TOP, END_FINALLY which
# would indicate try/else rather than try
return tokens[last - 3].kind not in frozenset(
("JUMP_FORWARD", "RETURN_VALUE")
("JUMP_FORWARD", "JUMP_BACK", "BREAK_LOOP", "RETURN_VALUE")
) or (tokens[last - 3] == "JUMP_FORWARD" and tokens[last - 3].attr != 2)
elif lhs == "tryelsestmt":
# We need to distinguish "try_except" from "tryelsestmt"; we do that
# by making sure that the jump before the except handler jumps to
# code somewhere before the end of the construct.
# This AST method is slower, but the token-only based approach
# didn't work as it failed with a "try" embedded inside a "try/else"
# since we can't detect COME_FROM boundaries.
if ast[3] == "except_handler":
except_handler = ast[3]
if except_handler[0] == "JUMP_FORWARD":
else_start = int(except_handler[0].pattr)
if last == len(tokens):
last -= 1
if tokens[last] == "COME_FROM" and isinstance:
last_offset = int(tokens[last].offset.split("_")[0])
return else_start >= last_offset
# The above test apparently isn't good enough, so we have additional
# checks distinguish "try_except" from "tryelsestmt". we do that
# by checking the jump before the "END_FINALLY".
# If we have:
# insn
# POP_TOP
# END_FINALLY
# COME_FROM
# then insn is neither a JUMP_FORWARD nor RETURN_VALUE,
# or if it is JUMP_FORWARD, then it can't be a JUMP_FORWARD to right after
# COME_FROM
if last == len(tokens):
last -= 1
while tokens[last - 1] == "COME_FROM" and tokens[last - 2] == "COME_FROM":
last -= 1
if tokens[last] == "COME_FROM" and tokens[last - 1] == "COME_FROM":
last -= 1
if (
tokens[last] == "COME_FROM"
and tokens[last - 1] == "END_FINALLY"
and tokens[last - 2] == "POP_TOP"
):
# A jump of 2 is a jump around POP_TOP, END_FINALLY which
# would indicate try/else rather than try
return tokens[last - 3].kind in frozenset(
("JUMP_FORWARD", "RETURN_VALUE")
) and (tokens[last - 3] != "JUMP_FORWARD" or tokens[last - 3].attr == 2)
return False

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2016-2020, 2023 Rocky Bernstein
# Copyright (c) 2016-2020, 2023-2024 Rocky Bernstein
# Copyright (c) 2005 by Dan Pascu <dan@windowmaker.org>
# Copyright (c) 2000-2002 by hartmut Goebel <hartmut@goebel.noris.de>
@@ -161,9 +161,9 @@ class Python27Parser(Python2Parser):
POP_BLOCK LOAD_CONST COME_FROM_WITH
WITH_CLEANUP END_FINALLY
withasstmt ::= expr SETUP_WITH store suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_WITH
WITH_CLEANUP END_FINALLY
with_as ::= expr SETUP_WITH store suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_WITH
WITH_CLEANUP END_FINALLY
whilestmt ::= SETUP_LOOP testexpr returns
_come_froms POP_BLOCK COME_FROM

View File

@@ -287,9 +287,9 @@ class Python3Parser(PythonParser):
POP_BLOCK LOAD_CONST COME_FROM_WITH
WITH_CLEANUP END_FINALLY
withasstmt ::= expr SETUP_WITH store suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_WITH
WITH_CLEANUP END_FINALLY
with_as ::= expr SETUP_WITH store suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_WITH
WITH_CLEANUP END_FINALLY
expr_jt ::= expr jmp_true
expr_jitop ::= expr JUMP_IF_TRUE_OR_POP
@@ -706,7 +706,7 @@ class Python3Parser(PythonParser):
# Note: BUILD_TUPLE_UNPACK_WITH_CALL gets considered by
# default because it starts with BUILD. So we'll set to ignore it from
# the start.
custom_ops_processed = set(("BUILD_TUPLE_UNPACK_WITH_CALL",))
custom_ops_processed = {"BUILD_TUPLE_UNPACK_WITH_CALL"}
# A set of instruction operation names that exist in the token stream.
# We use this customize the grammar that we create.
@@ -1240,7 +1240,7 @@ class Python3Parser(PythonParser):
) % (
pos_kw_tuple[0],
pos_kw_tuple[1],
"annotate_pair " * (annotate_args),
"annotate_tuple " * (annotate_args),
opname,
)
self.add_unique_rule(rule, opname, token.attr, customize)

View File

@@ -66,7 +66,7 @@ class Python30Parser(Python31Parser):
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE COME_FROM POP_TOP
withasstmt ::= expr setupwithas store suite_stmts_opt
with_as ::= expr setupwithas store suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_FINALLY
LOAD_FAST DELETE_FAST WITH_CLEANUP END_FINALLY
setupwithas ::= DUP_TOP LOAD_ATTR STORE_FAST LOAD_ATTR CALL_FUNCTION_0 setup_finally
@@ -222,12 +222,17 @@ class Python30Parser(Python31Parser):
# The were found using grammar coverage
while1stmt ::= SETUP_LOOP l_stmts COME_FROM JUMP_BACK COME_FROM_LOOP
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM_LOOP
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK else_suitel COME_FROM_LOOP
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK COME_FROM_LOOP
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK JUMP_BACK COME_FROM_LOOP
whileelsestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
else_suitel COME_FROM_LOOP
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK
COME_FROM_LOOP
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt JUMP_BACK POP_BLOCK JUMP_BACK
COME_FROM_LOOP
whilestmt ::= SETUP_LOOP testexpr returns POP_TOP POP_BLOCK COME_FROM_LOOP
withasstmt ::= expr SETUP_WITH store suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP END_FINALLY
with ::= expr SETUP_WITH POP_TOP suite_stmts_opt POP_BLOCK LOAD_CONST COME_FROM_WITH WITH_CLEANUP END_FINALLY
with_as ::= expr SETUP_WITH store suite_stmts_opt POP_BLOCK LOAD_CONST
COME_FROM_WITH WITH_CLEANUP END_FINALLY
with ::= expr SETUP_WITH POP_TOP suite_stmts_opt POP_BLOCK LOAD_CONST
COME_FROM_WITH WITH_CLEANUP END_FINALLY
# lc_body ::= LOAD_FAST expr LIST_APPEND
# lc_body ::= LOAD_NAME expr LIST_APPEND

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2016-2017, 2022 Rocky Bernstein
# Copyright (c) 2016-2017, 2022, 2024 Rocky Bernstein
"""
spark grammar differences over Python 3.2 for Python 3.1.
"""
@@ -23,7 +23,7 @@ class Python31Parser(Python32Parser):
# Keeps Python 3.1 "with .. as" designator in the same position as it is in other version.
setupwithas31 ::= setupwithas SETUP_FINALLY load delete
withasstmt ::= expr setupwithas31 store
with_as ::= expr setupwithas31 store
suite_stmts_opt
POP_BLOCK LOAD_CONST COME_FROM_FINALLY
load delete WITH_CLEANUP END_FINALLY

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2016-2017, 2022 Rocky Bernstein
# Copyright (c) 2016-2017, 2022-2024 Rocky Bernstein
"""
spark grammar differences over Python 3 for Python 3.2.
"""
@@ -84,7 +84,7 @@ class Python32Parser(Python3Parser):
for i, token in enumerate(tokens):
opname = token.kind
if opname.startswith("MAKE_FUNCTION_A"):
args_pos, args_kw, annotate_args = token.attr
args_pos, _, annotate_args = token.attr
# Check that there are 2 annotated params?
rule = (
"mkfunc_annotate ::= %s%sannotate_tuple "

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2017-2018 Rocky Bernstein
# Copyright (c) 2017-2018, 2022-2024 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
@@ -21,7 +21,6 @@ from uncompyle6.parsers.parse33 import Python33Parser
class Python34Parser(Python33Parser):
def p_misc34(self, args):
"""
expr ::= LOAD_ASSERT
@@ -54,39 +53,52 @@ class Python34Parser(Python33Parser):
_ifstmts_jump ::= c_stmts_opt JUMP_ABSOLUTE JUMP_FORWARD COME_FROM
genexpr_func ::= LOAD_ARG _come_froms FOR_ITER store comp_iter JUMP_BACK
if_exp_lambda ::= expr jmp_false expr return_if_lambda come_froms return_stmt_lambda LAMBDA_MARKER
return_if_lambda ::= RETURN_END_IF_LAMBDA come_froms
return_if_stmt ::= return_expr RETURN_END_IF POP_BLOCK
"""
def customize_grammar_rules(self, tokens, customize):
self.remove_rules("""
self.remove_rules(
"""
yield_from ::= expr expr YIELD_FROM
# 3.4.2 has this. 3.4.4 may now
# while1stmt ::= SETUP_LOOP l_stmts COME_FROM JUMP_BACK COME_FROM_LOOP
""")
"""
)
super(Python34Parser, self).customize_grammar_rules(tokens, customize)
return
class Python34ParserSingle(Python34Parser, PythonParserSingle):
pass
if __name__ == '__main__':
if __name__ == "__main__":
# Check grammar
p = Python34Parser()
p.check_grammar()
from xdis.version_info import IS_PYPY, PYTHON_VERSION_TRIPLE
if PYTHON_VERSION_TRIPLE[:2] == (3, 4):
lhs, rhs, tokens, right_recursive, dup_rhs = p.check_sets()
from uncompyle6.scanner import get_scanner
s = get_scanner(PYTHON_VERSION_TRIPLE, IS_PYPY)
opcode_set = set(s.opc.opname).union(set(
"""JUMP_BACK CONTINUE RETURN_END_IF COME_FROM
opcode_set = set(s.opc.opname).union(
set(
"""JUMP_BACK CONTINUE RETURN_END_IF COME_FROM
LOAD_GENEXPR LOAD_ASSERT LOAD_SETCOMP LOAD_DICTCOMP LOAD_CLASSNAME
LAMBDA_MARKER RETURN_LAST
""".split()))
""".split()
)
)
remain_tokens = set(tokens) - opcode_set
import re
remain_tokens = set([re.sub(r'_\d+$', '', t) for t in remain_tokens])
remain_tokens = set([re.sub('_CONT$', '', t) for t in remain_tokens])
remain_tokens = set([re.sub(r"_\d+$", "", t) for t in remain_tokens])
remain_tokens = set([re.sub("_CONT$", "", t) for t in remain_tokens])
remain_tokens = set(remain_tokens) - opcode_set
print(remain_tokens)
# print(sorted(p.rule2name.items()))

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