Commit Graph

45 Commits

Author SHA1 Message Date
rocky
c68b74a9c6 new dis - Python compisons involving tuples 2021-10-15 23:39:59 -04:00
rocky
5c16c73a6c Fix annotation transform for 3.7+
We were producing:

```
z: z: int = 5 on bytecode_3.7_run/02_var_annotate.pyc
```

because grammar went

     5. sstmt
        ann_assign (4) transformed by n_stmts: ('%|%[2]{attr}: %c\n', 0)
             0. ann_assign_init (3): ('%|%[2]{attr}: %c = %c\n', 0, 1)

The "ann_assign" added "z:". Instead we have now:

```
     5. sstmt
        ann_assign_init (3) transformed by n_stmts: ('%|%[2]{attr}: %c = %c\n', 0, 1)
```

Also, in the previous statement which appears in the listing (but is not
actually in the finaly tree) we had:

     4. sstmt
        assign (2): ('%|%c = %p\n', -1, (0, 200))
             0. expr
                L. L.   7        26  LOAD_CONST               5
             1. store

So we now preface the node type with "deleted", e.g.:

     4. deleted sstmt
        assign (2): ('%|%c = %p\n', -1, (0, 200))
             0. expr
                L. L.   7        26  LOAD_CONST               5
             1. store

to reduce confusion
2020-12-27 22:50:46 -05:00
rocky
78dbc8ae0f Adjust ann_assign_init rule...
We've reduced spurious `sstmt` reductions. The `ann_assign_init` rule needs
to adjust accordingly.
2020-11-03 18:07:42 -05:00
rocky
a215ee2f00 Use "co_consts" in docstring detection.
Note: this is an upheaval because we need to pass "code" or at least
"code.co_consts" to the docstring detection routine
2020-07-21 10:31:07 -04:00
rocky
0f80c38530 Better doc string detection
A bug in 2.7 test_descr.py revealed a problem with the way we were
detecting docstrings.

        __doc__ = DocDescr()

was getting confused with a docstring.

This program also reveals other bugs in 3.2+ but we'll deal with that
in another commit.
2020-07-19 20:31:50 -04:00
rocky
11be90758f Workaround bug detecting MAKE_FUNCTION docstrings 2020-06-26 07:17:31 -04:00
rocky
2a8daca25d Fix broken __doc__ transform yet again...
Hopefully by using first_child() we have something more robust now.
2020-06-17 10:12:56 -04:00
rocky
869e48877c Convert to use xdis 4.3.0 or greater 2020-04-16 08:41:53 -04:00
rocky
9caac7fc84 Small tweaks ...
* Remove unneeded Makefile
* sync n_ifelsesmt transform with decompyle3
2020-04-01 11:00:25 -04:00
rocky
e90455dcb8 transform ifelseif bugs 2020-02-13 04:31:16 -05:00
rocky
bf288b1871 Fix bug introduced by ast "tranform" change 2020-02-10 16:13:57 -05:00
rocky
76287162da Fix ifelif transformation for earlier Pythons 2020-02-10 11:16:32 -05:00
rocky
727dabff6a is_docsting needs to test for sstmts 2020-02-10 09:19:03 -05:00
rocky
7c73536b4a 3.6 "assert" and "or" handling bugs 2020-02-08 07:27:31 -05:00
rocky
9166fb54a1 Adjust a couple of "assert"s 2020-02-04 22:06:48 -05:00
rocky
68c9de60a5 Adjust assert transform for new "if_and" rule 2020-02-04 21:28:08 -05:00
rocky
04f8619cf1 Better docstring recognition 2020-02-02 13:02:37 -05:00
rocky
6fff0fc5a2 More assert transform opportunities 2020-02-02 06:46:48 -05:00
rocky
6e5666c001 Merge branch 'master' of github.com:rocky/python-uncompyle6 2020-02-02 05:37:37 -05:00
rocky
38e2b8a10b Go over docstring handling 2020-02-02 05:37:07 -05:00
rocky
5d1bf2dd9b adjust "assert" transformation due to grammar ...
simplification
2020-02-01 22:27:17 -05:00
rocky
e80e72e6ab ifelsestmt transform must object types more 2020-01-26 10:12:26 -05:00
rocky
118e21b2cd A recent changed bolixed docstrings...
fixa
2020-01-26 03:30:57 -05:00
rocky
33918bd9d2 More 3.x "if" checking. Abbreviate stmts->sstmt 2020-01-26 02:58:33 -05:00
rocky
96c9058cc1 Mini-sync with decompyle3:
go over runtests.sh 3.8 excludes
2020-01-23 07:00:53 -05:00
rocky
bc50825460 Conditional jumps to extended-arg JUMP_BACK...
this is a major reworking. But it leads the way forward to a
simpler grammar.
2020-01-22 05:32:27 -05:00
rocky
f56ad56021 Wacky string at beginning of fn which is not docstring...
3.7.6 test_fstring.py tests this.
2020-01-12 22:59:06 -05:00
rocky
061da83863 3.7 "import" fix 2020-01-11 07:37:28 -05:00
rocky
c3d7ba6dad 3.7 "imports" and "or" 2020-01-11 07:23:23 -05:00
rocky
6de57249ed Start 3.6+ var type annotations and decompyle3 merge...
Although overall an improvement, some new breakage
has occurred and should be fixed.
2020-01-01 01:42:00 -05:00
rocky
db2fdb30fd Tidy code.
* Don't use "str" as a variable name
* blacken helper and alphabetically order fns
* use helper function `find_code_node()` in transform `mk_func()`
2019-12-27 12:38:09 -05:00
rocky
37301ab49e Was dropping docstrings! Add in decompyle make_function36 2019-12-27 11:41:03 -05:00
rocky
28d9e66a53 Redo the way we handle complex literals and 3.7+ bug fixes...
In 3.7+ remove assert_expr* parser rules
Fix "call" precidence in 3.7+ for it children
2019-12-19 06:40:13 -05:00
rocky
0eaeb82d48 Sync a little with decompyle3 2019-12-15 08:07:02 -05:00
rocky
41b6e91286 More stringent transform test for assert 2019-12-14 11:31:13 -05:00
rocky
05f3dad32c Fix some 3.7+ "if"/"and" logic bugs 2019-12-11 06:56:43 -05:00
rocky
9b2e22cbaf Small "not" bug in prior commit 2019-12-10 16:12:01 -05:00
rocky
cea2c7e1dc One more "assert" transform 2019-12-10 15:46:26 -05:00
rocky
79c38441b5 Better "assert" transformation. More 3.8 tests 2019-12-10 10:43:01 -05:00
rocky
c6ddefcef5 Merging in recent 3.7 and 3.8 improvements from decompyle6
This rebases 3.7, 3.8 ...decompilation off of 3.7ish rather than a 3.4
base.

Add more 3.7 and 3.8 tests
2019-12-08 17:54:59 -05:00
rocky
bc8907e752 Guard again improper assert transform...
we see this happen in getheader() from 3.0.1/lib/python3.0/http/client.pyc
2019-11-15 22:19:17 -05:00
rocky
0ae4acff9e Remove extraneous iter() in "for" of list comp...
Fixes #272
2019-10-30 21:58:14 -04:00
rocky
d41ef3e5dc Pypy 3.6 tolerance 2019-10-28 14:46:45 -04:00
rocky
9bd85fe5a0 Correct assert{,2} transforms
Fixes #289
2019-09-23 08:26:16 -04:00
rocky
1ebfde6927 Add tree transformation phase...
if ... else if ... ->  if ... elif ..
if .. : raise AsssertionError ->  assert

Add options --tree=before --tree=after  -T expanded to include this

This code ported from decompyle3. x0ret did all the heavy lifting.
2019-08-21 09:00:09 -04:00