You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Merge branch 'master' into python-2.4
This commit is contained in:
BIN
test/bytecode_3.6/02_build_map_unpack_with_call.pyc
Normal file
BIN
test/bytecode_3.6/02_build_map_unpack_with_call.pyc
Normal file
Binary file not shown.
@@ -61,7 +61,6 @@ Type -h for for full help.""" % program
|
||||
sys.stderr.write(Usage_short)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
for file in files:
|
||||
if os.path.exists(files[0]):
|
||||
disassemble_file(file, sys.stdout, native)
|
||||
|
@@ -223,7 +223,6 @@ def main_bin():
|
||||
except (KeyboardInterrupt, OSError):
|
||||
pass
|
||||
|
||||
|
||||
if timestamp:
|
||||
print(time.strftime(timestampfmt))
|
||||
|
||||
|
@@ -40,7 +40,6 @@ class Python25Parser(Python26Parser):
|
||||
if self.version == 2.5:
|
||||
self.check_reduce['tryelsestmt'] = 'tokens'
|
||||
|
||||
|
||||
def reduce_is_invalid(self, rule, ast, tokens, first, last):
|
||||
super(Python25Parser, self).reduce_is_invalid(rule, ast, tokens, first, last)
|
||||
|
||||
|
@@ -115,8 +115,10 @@ if __name__ == '__main__':
|
||||
""".split()))
|
||||
remain_tokens = set(tokens) - opcode_set
|
||||
import re
|
||||
remain_tokens = set([re.sub('_\d+$','', t) for t in remain_tokens])
|
||||
remain_tokens = set([re.sub('_CONT$','', t) for t in remain_tokens])
|
||||
remain_tokens = set([re.sub('_\d+$', '', t)
|
||||
for t in remain_tokens])
|
||||
remain_tokens = set([re.sub('_CONT$', '', t)
|
||||
for t in remain_tokens])
|
||||
remain_tokens = set(remain_tokens) - opcode_set
|
||||
print(remain_tokens)
|
||||
# p.dumpGrammar()
|
||||
|
@@ -551,7 +551,8 @@ class Python3Parser(PythonParser):
|
||||
elif opname_base in ('BUILD_LIST', 'BUILD_TUPLE', 'BUILD_SET'):
|
||||
v = token.attr
|
||||
rule = ('build_list ::= ' + 'expr1024 ' * int(v//1024) +
|
||||
'expr32 ' * int((v//32)%32) + 'expr '*(v%32) + opname)
|
||||
'expr32 ' * int((v//32) % 32) +
|
||||
'expr ' * (v % 32) + opname)
|
||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||
if opname_base == 'BUILD_TUPLE':
|
||||
rule = ('load_closure ::= %s%s' % (('LOAD_CLOSURE ' * v), opname))
|
||||
|
@@ -23,5 +23,5 @@ class Scanner15(scan.Scanner21):
|
||||
self.opc = opcode_15
|
||||
self.opname = opcode_15.opname
|
||||
self.version = 1.5
|
||||
self.genexpr_name = '<generator expression>';
|
||||
self.genexpr_name = '<generator expression>'
|
||||
return
|
||||
|
@@ -41,7 +41,7 @@ class Scanner2(scan.Scanner):
|
||||
self.jump_forward = frozenset([self.opc.JUMP_ABSOLUTE, self.opc.JUMP_FORWARD])
|
||||
# This is the 2.5+ default
|
||||
# For <2.5 it is <generator expression>
|
||||
self.genexpr_name = '<genexpr>';
|
||||
self.genexpr_name = '<genexpr>'
|
||||
|
||||
@staticmethod
|
||||
def unmangle_name(name, classname):
|
||||
@@ -72,7 +72,6 @@ class Scanner2(scan.Scanner):
|
||||
varnames = co.co_varnames
|
||||
return free, names, varnames
|
||||
|
||||
|
||||
def ingest(self, co, classname=None, code_objects={}, show_asm=None):
|
||||
"""
|
||||
Pick out tokens from an uncompyle6 code object, and transform them,
|
||||
@@ -104,7 +103,7 @@ class Scanner2(scan.Scanner):
|
||||
|
||||
customize = {}
|
||||
if self.is_pypy:
|
||||
customize['PyPy'] = 1;
|
||||
customize['PyPy'] = 1
|
||||
|
||||
Token = self.Token # shortcut
|
||||
|
||||
@@ -465,7 +464,6 @@ class Scanner2(scan.Scanner):
|
||||
self.ignore_if.add(except_match)
|
||||
return None
|
||||
|
||||
|
||||
self.ignore_if.add(except_match)
|
||||
self.not_continue.add(jmp)
|
||||
return jmp
|
||||
|
@@ -23,5 +23,5 @@ class Scanner21(scan.Scanner22):
|
||||
self.opc = opcode_21
|
||||
self.opname = opcode_21.opname
|
||||
self.version = 2.1
|
||||
self.genexpr_name = '<generator expression>';
|
||||
self.genexpr_name = '<generator expression>'
|
||||
return
|
||||
|
@@ -23,7 +23,7 @@ class Scanner22(scan.Scanner23):
|
||||
self.opc = opcode_22
|
||||
self.opname = opcode_22.opname
|
||||
self.version = 2.2
|
||||
self.genexpr_name = '<generator expression>';
|
||||
self.genexpr_name = '<generator expression>'
|
||||
self.parent_ingest = self.ingest
|
||||
self.ingest = self.ingest22
|
||||
return
|
||||
|
@@ -165,7 +165,7 @@ class Scanner3(Scanner):
|
||||
|
||||
customize = {}
|
||||
if self.is_pypy:
|
||||
customize['PyPy'] = 1;
|
||||
customize['PyPy'] = 1
|
||||
|
||||
self.code = array('B', co.co_code)
|
||||
self.build_lines_data(co)
|
||||
@@ -705,9 +705,9 @@ class Scanner3(Scanner):
|
||||
# everything inside inner 'or' jumps and midline ifs
|
||||
match = self.rem_or(start, self.next_stmt[offset],
|
||||
self.opc.POP_JUMP_IF_FALSE, target)
|
||||
## We can't remove mid-line ifs because line structures have changed
|
||||
## from restructBytecode().
|
||||
## match = self.remove_mid_line_ifs(match)
|
||||
# We can't remove mid-line ifs because line structures have changed
|
||||
# from restructBytecode().
|
||||
# match = self.remove_mid_line_ifs(match)
|
||||
|
||||
# If we still have any offsets in set, start working on it
|
||||
if match:
|
||||
|
@@ -163,7 +163,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
None)
|
||||
|
||||
def set_pos_info(self, node, start, finish, name=None):
|
||||
if name == None: name = self.name
|
||||
if name is None: name = self.name
|
||||
if hasattr(node, 'offset'):
|
||||
self.offsets[name, node.offset] = \
|
||||
NodeInfo(node = node, start = start, finish = finish)
|
||||
@@ -622,7 +622,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
n = ast[iter_index]
|
||||
assert n == 'list_iter'
|
||||
|
||||
## FIXME: I'm not totally sure this is right.
|
||||
# FIXME: I'm not totally sure this is right.
|
||||
|
||||
# find innermost node
|
||||
if_node = None
|
||||
|
@@ -490,7 +490,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.write("\n" + self.indent + INDENT_PER_LEVEL[:-1])
|
||||
return self.line_number
|
||||
|
||||
|
||||
def customize_for_version(self, is_pypy, version):
|
||||
if is_pypy:
|
||||
########################
|
||||
@@ -535,7 +534,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
'raise_stmt2': ( '%|raise %c from %c\n', 0, 1),
|
||||
})
|
||||
|
||||
|
||||
if version < 2.0:
|
||||
TABLE_DIRECT.update({
|
||||
'importlist': ( '%C', (0, maxint, ', ') ),
|
||||
@@ -623,7 +621,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.prune() # stop recursing
|
||||
self.n_mkfunc_annotate = n_mkfunc_annotate
|
||||
|
||||
|
||||
if version >= 3.4:
|
||||
########################
|
||||
# Python 3.4+ Additions
|
||||
@@ -640,6 +637,8 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.f.write(', **')
|
||||
pass
|
||||
pass
|
||||
if version >= 3.6:
|
||||
self.f.write(')')
|
||||
self.prune()
|
||||
pass
|
||||
self.n_unmapexpr = n_unmapexpr
|
||||
@@ -652,6 +651,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
'fstring_expr': ( "{%c%{conversion}}", 0),
|
||||
'fstring_single': ( "f'{%c%{conversion}}'", 0),
|
||||
'fstring_multi': ( "f'%c'", 0),
|
||||
'func_args36': ( "%c(**", 0),
|
||||
})
|
||||
|
||||
FSTRING_CONVERSION_MAP = {1: '!s', 2: '!r', 3: '!a'}
|
||||
@@ -1150,7 +1150,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
assert n == 'lc_body'
|
||||
self.write( '[ ')
|
||||
|
||||
|
||||
if self.version >= 2.7:
|
||||
expr = n[0]
|
||||
list_iter = node[-1]
|
||||
@@ -1350,7 +1349,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
n = ast[iter_index]
|
||||
assert n == 'list_iter', n
|
||||
|
||||
## FIXME: I'm not totally sure this is right.
|
||||
# FIXME: I'm not totally sure this is right.
|
||||
|
||||
# find innermost node
|
||||
if_node = None
|
||||
@@ -2158,7 +2157,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.println()
|
||||
del ast[i]
|
||||
|
||||
|
||||
# the function defining a class normally returns locals(); we
|
||||
# don't want this to show up in the source, thus remove the node
|
||||
if len(ast) > 0 and ast[-1][0] == RETURN_LOCALS:
|
||||
|
Reference in New Issue
Block a user