X Tutup
Skip to content

Commit cd8cbf9

Browse files
committed
Add 3.5 matrix mult ops
We now run 3.5 verifycation so we need to remove some of the tests that fail to verify pending fixing.
1 parent accc959 commit cd8cbf9

File tree

9 files changed

+19
-9
lines changed

9 files changed

+19
-9
lines changed

README.rst

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ Why this?
2020

2121
There were a number of decompyle, uncompile, uncompyle2, uncompyle3
2222
forks around. All of them come basically from the same code base, and
23-
almost all of them not maintained very well. This code pulls these together
24-
and addresses a number of open issues in those.
23+
almost all of them no longer maintained or worked on. Only one handled
24+
Python 3, and even there, only 3.2. This code pulls these together,
25+
handles a wide range of bytecodes and addresses a number of open
26+
issues in previous forks.
2527

2628
What makes this different from other CPython bytecode decompilers? Its
2729
ability to deparse just fragments and give source-code information
@@ -85,7 +87,7 @@ Known Bugs/Restrictions
8587
-----------------------
8688

8789
Python 2 deparsing decompiles and verifies from Python 2.3.7 to Python
88-
3.5.1 on the standard library packages I have on my system.
90+
3.4.2 on the standard library packages I have on my system.
8991

9092
(Verification is the process of decompiling bytecode, compiling with a
9193
Python for that byecode version, and then comparing the byetcode
@@ -96,13 +98,9 @@ Later distributions average about 200 files. At this point, 2.7
9698
decompilation is better than uncompyle2. A number of bugs have been
9799
fixed.
98100

99-
That said, I'm sure down the line more problems will turn up. The
100-
decompilation process uses a number of heuristics that may prove
101-
faulty.
102-
103-
There are a few constructs that still need to be added to Python 3.5.
101+
Python 3.5 largely works, but still has some bugs in it.
104102
Python 3.6 changes things drastically by using word codes rather than
105-
byte codes. So that will be yet another challenge.
103+
byte codes, and that needs to be addressed.
106104

107105
There is lots to do, so please dig in and help.
108106

test/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ check-3.4: check-bytecode check-3.4-ok check-2.7-ok
3636

3737
#: Run working tests from Python 3.5
3838
check-3.5: check-bytecode
39+
$(PYTHON) test_pythonlib.py --bytecode-3.5 --verify $(COMPILE)
3940

4041
#: Check deparsing only, but from a different Python version
4142
check-disasm:
194 Bytes
Binary file not shown.
File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Tests Python 3.5+'s ops
2+
3+
# BINARY_MATRIX_MULTIPLY and INPLACE_MATRIX_MULTIPLY
4+
# code taken from pycdc tests/35_matrix_mult_oper.pyc.src
5+
6+
m = [1, 2] @ [3, 4]
7+
m @= [5, 6]

uncompyle6/parsers/parse3.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,8 @@ def p_35on(self, args):
602602
POP_BLOCK LOAD_CONST COME_FROM
603603
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
604604
605+
inplace_op ::= INPLACE_MATRIX_MULTIPLY
606+
binary_op ::= BINARY_MATRIX_MULTIPLY
605607
606608
# Python 3.5+ does jump optimization
607609
# In <.3.5 the below is a JUMP_FORWARD to a JUMP_ABSOLUTE.

uncompyle6/semantics/pysource.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
'BINARY_SUBTRACT': ( '-' ,),
163163
'BINARY_MULTIPLY': ( '*' ,),
164164
'BINARY_DIVIDE': ( '/' ,),
165+
'BINARY_MATRIX_MULTIPLY': ( '@' ,),
165166
'BINARY_TRUE_DIVIDE': ( '/' ,),
166167
'BINARY_FLOOR_DIVIDE': ( '//' ,),
167168
'BINARY_MODULO': ( '%%',),
@@ -174,6 +175,7 @@
174175
'INPLACE_ADD': ( '+=' ,),
175176
'INPLACE_SUBTRACT': ( '-=' ,),
176177
'INPLACE_MULTIPLY': ( '*=' ,),
178+
'INPLACE_MATRIX_MULTIPLY': ( '@=' ,),
177179
'INPLACE_DIVIDE': ( '/=' ,),
178180
'INPLACE_TRUE_DIVIDE': ( '/=' ,),
179181
'INPLACE_FLOOR_DIVIDE': ( '//=' ,),

0 commit comments

Comments
 (0)
X Tutup