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 Python 1.4 decompilation ...
Tidy up test code for issue 162 and comments for some disassembly massaging.
This commit is contained in:
BIN
test/bytecode_1.4/emacs.pyc
Normal file
BIN
test/bytecode_1.4/emacs.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
test/bytecode_3.1_run/05_dict_comp.pyc
Normal file
BIN
test/bytecode_3.1_run/05_dict_comp.pyc
Normal file
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,7 @@
|
||||
# Bug was in dictionary comprehension involving "if not"
|
||||
# Issue #162
|
||||
#
|
||||
# This code is RUNNABLE!
|
||||
def x(s):
|
||||
return {k: v
|
||||
for (k, v) in s
|
||||
|
30
uncompyle6/parsers/parse14.py
Normal file
30
uncompyle6/parsers/parse14.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright (c) 2018 Rocky Bernstein
|
||||
|
||||
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||
from uncompyle6.parser import PythonParserSingle
|
||||
from uncompyle6.parsers.parse15 import Python15Parser
|
||||
|
||||
class Python14Parser(Python15Parser):
|
||||
|
||||
def p_misc14(self, args):
|
||||
"""
|
||||
# Nothing here yet, but will need to add UNARY_CALL, BINARY_CALL,
|
||||
# RAISE_EXCEPTION, BUILD_FUNCTION, UNPACK_ARG, UNPACK_VARARG, LOAD_LOCAL,
|
||||
# SET_FUNC_ARGS, and RESERVE_FAST
|
||||
"""
|
||||
def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG):
|
||||
super(Python14Parser, self).__init__(debug_parser)
|
||||
self.customized = {}
|
||||
|
||||
|
||||
class Python14ParserSingle(Python14Parser, PythonParserSingle):
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Check grammar
|
||||
p = Python14Parser()
|
||||
p.check_grammar()
|
||||
p.dump_grammar()
|
||||
|
||||
# local variables:
|
||||
# tab-width: 4
|
@@ -23,7 +23,7 @@ class Python15Parser(Python21Parser):
|
||||
importlist ::= IMPORT_FROM
|
||||
"""
|
||||
|
||||
class Python15ParserSingle(Python21Parser, PythonParserSingle):
|
||||
class Python15ParserSingle(Python15Parser, PythonParserSingle):
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@@ -37,7 +37,7 @@ from xdis.util import code2num
|
||||
|
||||
# The byte code versions we support.
|
||||
# Note: these all have to be floats
|
||||
PYTHON_VERSIONS = frozenset((1.5,
|
||||
PYTHON_VERSIONS = frozenset((1.4, 1.5,
|
||||
2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7,
|
||||
3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7))
|
||||
|
||||
|
27
uncompyle6/scanners/scanner14.py
Normal file
27
uncompyle6/scanners/scanner14.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright (c) 2018 by Rocky Bernstein
|
||||
"""
|
||||
Python 1.4 bytecode decompiler massaging.
|
||||
|
||||
This massages tokenized 1.4 bytecode to make it more amenable for
|
||||
grammar parsing.
|
||||
"""
|
||||
|
||||
import uncompyle6.scanners.scanner15 as scan
|
||||
# from uncompyle6.scanners.scanner26 import ingest as ingest26
|
||||
|
||||
# bytecode verification, verify(), uses JUMP_OPs from here
|
||||
from xdis.opcodes import opcode_14
|
||||
JUMP_OPS = opcode_14.JUMP_OPS
|
||||
|
||||
# We base this off of 1.5 instead of the other way around
|
||||
# because we cleaned things up this way.
|
||||
# The history is that 2.7 support is the cleanest,
|
||||
# then from that we got 2.6 and so on.
|
||||
class Scanner14(scan.Scanner15):
|
||||
def __init__(self, show_asm=False):
|
||||
scan.Scanner15.__init__(self, show_asm)
|
||||
self.opc = opcode_14
|
||||
self.opname = opcode_14.opname
|
||||
self.version = 1.4
|
||||
self.genexpr_name = '<generator expression>'
|
||||
return
|
@@ -1,6 +1,6 @@
|
||||
# Copyright (c) 2016-2017 by Rocky Bernstein
|
||||
# Copyright (c) 2016-2018 by Rocky Bernstein
|
||||
"""
|
||||
Python 1.5 bytecode decompiler scanner.
|
||||
Python 1.5 bytecode decompiler massaging.
|
||||
|
||||
This massages tokenized 1.5 bytecode to make it more amenable for
|
||||
grammar parsing.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Copyright (c) 2016-2017 by Rocky Bernstein
|
||||
# Copyright (c) 2016-2018 by Rocky Bernstein
|
||||
"""
|
||||
Python 2.1 bytecode scanner/deparser
|
||||
Python 2.1 bytecode massaging.
|
||||
|
||||
This massages tokenized 2.1 bytecode to make it more amenable for
|
||||
grammar parsing.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Copyright (c) 2016-2017 by Rocky Bernstein
|
||||
# Copyright (c) 2016-2018 by Rocky Bernstein
|
||||
"""
|
||||
Python 2.2 bytecode ingester.
|
||||
Python 2.2 bytecode massaging.
|
||||
|
||||
This massages tokenized 2.2 bytecode to make it more amenable for
|
||||
grammar parsing.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Copyright (c) 2016-2017 by Rocky Bernstein
|
||||
# Copyright (c) 2016-2018 by Rocky Bernstein
|
||||
"""
|
||||
Python 2.3 bytecode scanner/deparser
|
||||
Python 2.3 bytecode massaging.
|
||||
|
||||
This massages tokenized 2.3 bytecode to make it more amenable for
|
||||
grammar parsing.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Copyright (c) 2016-2017 by Rocky Bernstein
|
||||
"""
|
||||
Python 2.4 bytecode scanner/deparser
|
||||
Python 2.4 bytecode massaging.
|
||||
|
||||
This massages tokenized 2.7 bytecode to make it more amenable for
|
||||
grammar parsing.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Copyright (c) 2015-2017 by Rocky Bernstein
|
||||
# Copyright (c) 2015-2018 by Rocky Bernstein
|
||||
"""
|
||||
Python 2.5 bytecode scanner/deparser
|
||||
Python 2.5 bytecode massaging.
|
||||
|
||||
This overlaps Python's 2.5's dis module, but it can be run from
|
||||
Python 3 and other versions of Python. Also, we save token
|
||||
|
Reference in New Issue
Block a user