X Tutup
Skip to content

Commit bdd8a9f

Browse files
committed
Can't handle python 2.3 on 3.x for now
1 parent ebcb1d0 commit bdd8a9f

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

test/Makefile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ check:
2020
$(MAKE) check-$$PYTHON_VERSION
2121

2222
#: Run working tests from Python 2.6 or 2.7
23-
check-2.6 check-2.7: check-bytecode check-2.7-ok
23+
check-2.6 check-2.7: check-bytecode-2 check-bytecode-3 check-2.7-ok
2424

2525
#: Run working tests from Python 3.2
2626
check-3.2: check-bytecode
@@ -41,14 +41,17 @@ check-3.4: check-bytecode check-3.4-ok check-2.7-ok
4141
check-disasm:
4242
$(PYTHON) dis-compare.py
4343

44-
#: Check deparsing bytecode only
44+
#: Check deparsing bytecode 2.x only
4545
check-bytecode-2:
46-
$(PYTHON) test_pythonlib.py --bytecode-2.5 --bytecode-2.6 --bytecode-2.7
46+
$(PYTHON) test_pythonlib.py --bytecode-2.3 --bytecode-2.5 --bytecode-2.6 --bytecode-2.7
47+
48+
#: Check deparsing bytecode 3.x only
49+
check-bytecode-3:
50+
$(PYTHON) test_pythonlib.py --bytecode-3.2 --bytecode-3.3 --bytecode-3.4 --bytecode-3.5
4751

48-
#: Check deparsing bytecode only
49-
check-bytecode:
50-
$(PYTHON) test_pythonlib.py --bytecode-2.3 --bytecode-2.5 --bytecode-2.6 --bytecode-2.7 \
51-
--bytecode-3.2 --bytecode-3.3 --bytecode-3.4 --bytecode-3.5
52+
#: Check deparsing bytecode that works running Python 2 and Python 3
53+
check-bytecode: check-bytecode-3
54+
$(PYTHON) test_pythonlib.py --bytecode-2.5 --bytecode-2.6 --bytecode-2.7
5255

5356
#: Check deparsing Python 2.3
5457
check-bytecode-2.3:

uncompyle6/scanner.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
from uncompyle6.scanners.tok import Token
2323

2424
# The byte code versions we support
25-
PYTHON_VERSIONS = (2.3, 2.4, 2.5, 2.6, 2.7, 3.2, 3.3, 3.4, 3.5)
25+
if PYTHON3:
26+
# Need to work out Python 2.3. ord's in PYTHON3
27+
PYTHON_VERSIONS = (2.5, 2.6, 2.7, 3.2, 3.3, 3.4, 3.5)
28+
else:
29+
PYTHON_VERSIONS = (2.3, 2.5, 2.6, 2.7, 3.2, 3.3, 3.4, 3.5)
2630

2731
# FIXME: DRY
2832
if PYTHON3:
@@ -268,12 +272,18 @@ def restrict_to_parent(self, target, parent):
268272
target = parent['end']
269273
return target
270274

271-
def get_scanner(version, show_asm=False):
275+
def get_scanner(version, show_asm=None):
272276
# Pick up appropriate scanner
273277
if version in PYTHON_VERSIONS:
274278
v_str = "%s" % (int(version * 10))
275279
exec("import uncompyle6.scanners.scanner%s as scan" % v_str)
276-
exec("scanner = scan.Scanner%s(show_asm=show_asm)" % v_str)
280+
if PYTHON3:
281+
import importlib
282+
scan = importlib.import_module("uncompyle6.scanners.scanner%s" % v_str)
283+
if False: print(scan) # Avoid unused scan
284+
else:
285+
exec("import uncompyle6.scanners.scanner%s as scan" % v_str)
286+
scanner = eval("scan.Scanner%s(show_asm=show_asm)" % v_str)
277287
else:
278288
raise RuntimeError("Unsupported Python version %s" % version)
279289
return scanner

uncompyle6/scanners/scanner23.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"""
1111

1212
from uncompyle6.scanners.scanner2 import Scanner2
13+
from uncompyle6.scanner import L65536
1314

1415
class Scanner23(Scanner2):
1516
def __init__(self, show_asm=None):
@@ -60,7 +61,7 @@ def disassemble(self, co, code_objects={}, show_asm=None):
6061
extended_arg = 0
6162
i += 2
6263
if op == self.opc.EXTENDED_ARG:
63-
extended_arg = oparg * 65536L
64+
extended_arg = oparg * L65536
6465
if op in self.opc.hasconst:
6566
const = co.co_consts[oparg]
6667
# We can't use inspect.iscode() because we may be

0 commit comments

Comments
 (0)
X Tutup