X Tutup
Skip to content

Commit dd661bc

Browse files
committed
Start accepting Python 3.1 bytecode
1 parent c4e6af6 commit dd661bc

File tree

6 files changed

+50
-3
lines changed

6 files changed

+50
-3
lines changed

test/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ check:
2323
check-2.6 check-2.7: check-bytecode-2 check-bytecode-3 check-2.7-ok
2424

2525
#: Run working tests from Python 3.1
26-
check-3.2: check-bytecode
26+
check-3.1: check-bytecode
2727
$(PYTHON) test_pythonlib.py --bytecode-3.1 --verify $(COMPILE)
2828

2929
#: Run working tests from Python 3.2
@@ -91,6 +91,10 @@ check-bytecode-2.6:
9191
check-bytecode-2.7:
9292
$(PYTHON) test_pythonlib.py --bytecode-2.7
9393

94+
#: Check deparsing Python 3.1
95+
check-bytecode-3.1:
96+
$(PYTHON) test_pythonlib.py --bytecode-3.1
97+
9498
#: Check deparsing Python 3.2
9599
check-bytecode-3.2:
96100
$(PYTHON) test_pythonlib.py --bytecode-3.2
2.16 KB
Binary file not shown.

test/test_pyenvlib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
'pypy-2.4.0', 'pypy-2.6.1',
3232
'pypy-5.0.1', 'pypy-5.3.1',
3333
'2.7.10', '2.7.11', '2.7.12',
34-
'3.2.6', '3.3.5', '3.3.6', '3.4.2', '3.5.1')
34+
'3.1.5', '3.2.6', '3.3.5', '3.3.6',
35+
'3.4.2', '3.5.1')
3536

3637
target_base = '/tmp/py-dis/'
3738
lib_prefix = os.path.join(os.environ['HOME'], '.pyenv/versions')

test/test_pythonlib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ def get_srcdir():
7979
pass
8080

8181
for vers in (2.2, 2.3, 2.4, 2.5, 2.6, 2.7,
82-
3.2, 3.3, 3.4, 3.5, 3.6, 'pypy3.2', 'pypy2.7'):
82+
3.1, 3.2, 3.3,
83+
3.4, 3.5, 3.6, 'pypy3.2', 'pypy2.7'):
8384
bytecode = "bytecode_%s" % vers
8485
key = "bytecode-%s" % vers
8586
test_options[key] = (bytecode, PYC, bytecode, vers)

uncompyle6/scanners/scanner31.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) 2015-2016 by Rocky Bernstein
2+
"""
3+
Python 3.2 bytecode scanner/deparser
4+
5+
This sets up opcodes Python's 3.2 and calls a generalized
6+
scanner routine for Python 3.
7+
"""
8+
9+
from __future__ import print_function
10+
11+
# bytecode verification, verify(), uses JUMP_OPs from here
12+
from xdis.opcodes import opcode_32 as opc
13+
JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs)
14+
15+
from uncompyle6.scanners.scanner3 import Scanner3
16+
class Scanner31(Scanner3):
17+
18+
def __init__(self, show_asm=None, is_pypy=False):
19+
Scanner3.__init__(self, 3.1, show_asm, is_pypy)
20+
return
21+
pass
22+
23+
if __name__ == "__main__":
24+
from uncompyle6 import PYTHON_VERSION
25+
if PYTHON_VERSION == 3.1:
26+
import inspect
27+
co = inspect.currentframe().f_code
28+
tokens, customize = Scanner32().ingest(co)
29+
for t in tokens:
30+
print(t)
31+
pass
32+
else:
33+
print("Need to be Python 3.1 to demo; I am %s." %
34+
PYTHON_VERSION)

uncompyle6/verify.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ def cmp_code_objects(version, is_pypy, code_obj1, code_obj2,
201201
else:
202202
import uncompyle6.scanners.scanner27 as scan
203203
scanner = scan.Scanner27()
204+
elif version == 3.1:
205+
if is_pypy:
206+
import uncompyle6.scanners.pypy31 as scan
207+
scanner = scan.ScannerPyPy31()
208+
else:
209+
import uncompyle6.scanners.scanner32 as scan
210+
scanner = scan.Scanner32()
204211
elif version == 3.2:
205212
if is_pypy:
206213
import uncompyle6.scanners.pypy32 as scan

0 commit comments

Comments
 (0)
X Tutup