You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Start to handle Python 3.1 bytecode
This commit is contained in:
2
Makefile
2
Makefile
@@ -33,7 +33,7 @@ check-2.7 check-3.3 check-3.4: pytest
|
||||
|
||||
#: Tests for Python 3.2 and 3.5 - pytest doesn't work here
|
||||
# Or rather 3.5 doesn't work not on Travis
|
||||
check-3.2 check-3.5 check-3.6:
|
||||
check-3.1 check-3.2 check-3.5 check-3.6:
|
||||
$(MAKE) -C test $@
|
||||
|
||||
#:Tests for Python 2.6 (doesn't have pytest)
|
||||
|
@@ -22,6 +22,10 @@ check:
|
||||
#: Run working tests from Python 2.6 or 2.7
|
||||
check-2.6 check-2.7: check-bytecode-2 check-bytecode-3 check-2.7-ok
|
||||
|
||||
#: Run working tests from Python 3.1
|
||||
check-3.2: check-bytecode
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.1 --verify $(COMPILE)
|
||||
|
||||
#: Run working tests from Python 3.2
|
||||
check-3.2: check-bytecode
|
||||
$(PYTHON) test_pythonlib.py --bytecode-3.2 --verify $(COMPILE)
|
||||
|
@@ -590,7 +590,12 @@ def get_python_parser(
|
||||
pass
|
||||
else:
|
||||
import uncompyle6.parsers.parse3 as parse3
|
||||
if version == 3.2:
|
||||
if version == 3.1:
|
||||
if compile_mode == 'exec':
|
||||
p = parse3.Python31Parser(debug_parser)
|
||||
else:
|
||||
p = parse3.Python31ParserSingle(debug_parser)
|
||||
elif version == 3.2:
|
||||
if compile_mode == 'exec':
|
||||
p = parse3.Python32Parser(debug_parser)
|
||||
else:
|
||||
|
@@ -635,6 +635,15 @@ class Python3Parser(PythonParser):
|
||||
return
|
||||
|
||||
|
||||
class Python31Parser(Python3Parser):
|
||||
|
||||
def p_31(self, args):
|
||||
"""
|
||||
# Store locals is only in Python 3.0 to 3.3
|
||||
stmt ::= store_locals
|
||||
store_locals ::= LOAD_FAST STORE_LOCALS
|
||||
"""
|
||||
|
||||
class Python32Parser(Python3Parser):
|
||||
|
||||
def p_32(self, args):
|
||||
@@ -660,6 +669,9 @@ class Python3ParserSingle(Python3Parser, PythonParserSingle):
|
||||
pass
|
||||
|
||||
|
||||
class Python31ParserSingle(Python31Parser, PythonParserSingle):
|
||||
pass
|
||||
|
||||
class Python32ParserSingle(Python32Parser, PythonParserSingle):
|
||||
pass
|
||||
|
||||
|
@@ -22,7 +22,8 @@ from uncompyle6 import PYTHON3, IS_PYPY
|
||||
from uncompyle6.scanners.tok import Token
|
||||
|
||||
# The byte code versions we support
|
||||
PYTHON_VERSIONS = (2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.6)
|
||||
PYTHON_VERSIONS = (2.2, 2.3, 2.4, 2.5, 2.6, 2.7,
|
||||
3.1, 3.2, 3.3, 3.4, 3.5, 3.6)
|
||||
|
||||
# FIXME: DRY
|
||||
if PYTHON3:
|
||||
|
@@ -52,10 +52,9 @@ class Scanner3(Scanner):
|
||||
# Note: super initilization above initializes self.opc
|
||||
|
||||
# Opcodes that can start a statement.
|
||||
self.statement_opcodes = frozenset([
|
||||
statement_opcodes = [
|
||||
self.opc.SETUP_LOOP, self.opc.BREAK_LOOP, self.opc.CONTINUE_LOOP,
|
||||
self.opc.SETUP_FINALLY, self.opc.END_FINALLY, self.opc.SETUP_EXCEPT,
|
||||
self.opc.SETUP_WITH,
|
||||
self.opc.POP_BLOCK, self.opc.STORE_FAST, self.opc.DELETE_FAST,
|
||||
self.opc.STORE_DEREF,
|
||||
|
||||
@@ -67,7 +66,12 @@ class Scanner3(Scanner):
|
||||
|
||||
self.opc.RETURN_VALUE, self.opc.RAISE_VARARGS, self.opc.POP_TOP,
|
||||
self.opc.PRINT_EXPR, self.opc.JUMP_ABSOLUTE
|
||||
])
|
||||
]
|
||||
|
||||
if version >= 3.2:
|
||||
statement_opcodes.append(self.opc.SETUP_WITH)
|
||||
|
||||
self.statement_opcodes = frozenset(statement_opcodes)
|
||||
|
||||
# Opcodes that can start a designator non-terminal.
|
||||
# FIXME: JUMP_ABSOLUTE is weird. What's up with that?
|
||||
|
Reference in New Issue
Block a user