You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Some Python 3.0 fixes...
Needs more in this direction though.
This commit is contained in:
@@ -77,6 +77,19 @@ def disco_loop(disasm, queue, real_out):
|
||||
pass
|
||||
pass
|
||||
|
||||
def disassemble_fp(fp, outstream=None):
|
||||
"""
|
||||
disassemble Python byte-code from an open file
|
||||
"""
|
||||
(version, timestamp, magic_int, co, is_pypy,
|
||||
source_size) = load_from_fp(fp)
|
||||
if type(co) == list:
|
||||
for con in co:
|
||||
disco(version, con, outstream)
|
||||
else:
|
||||
disco(version, co, outstream, is_pypy=is_pypy)
|
||||
co = None
|
||||
|
||||
def disassemble_file(filename, outstream=None):
|
||||
"""
|
||||
disassemble Python byte-code file (.pyc)
|
||||
|
@@ -22,8 +22,6 @@ class Python30Parser(Python31Parser):
|
||||
# it is 2.7 or 3.1. So we have a number of 2.6ish (and before) rules below
|
||||
|
||||
_ifstmts_jump ::= c_stmts_opt JUMP_FORWARD _come_froms POP_TOP COME_FROM
|
||||
jmp_true ::= JUMP_IF_TRUE POP_TOP
|
||||
jmp_false ::= JUMP_IF_FALSE POP_TOP
|
||||
|
||||
# Used to keep index order the same in semantic actions
|
||||
jb_pop_top ::= JUMP_BACK POP_TOP
|
||||
@@ -39,6 +37,16 @@ class Python30Parser(Python31Parser):
|
||||
LOAD_FAST DELETE_FAST WITH_CLEANUP END_FINALLY
|
||||
setupwithas ::= DUP_TOP LOAD_ATTR STORE_FAST LOAD_ATTR CALL_FUNCTION_0 setup_finally
|
||||
setup_finally ::= STORE_FAST SETUP_FINALLY LOAD_FAST DELETE_FAST
|
||||
|
||||
# In many ways 3.0 is like 2.6. The below rules in fact are the same or similar.
|
||||
|
||||
jmp_true ::= JUMP_IF_TRUE POP_TOP
|
||||
jmp_false ::= JUMP_IF_FALSE POP_TOP
|
||||
for_block ::= l_stmts_opt _come_froms POP_TOP JUMP_BACK
|
||||
except_handler ::= JUMP_FORWARD COME_FROM_EXCEPT except_stmts
|
||||
POP_TOP END_FINALLY come_froms
|
||||
return_if_stmt ::= ret_expr RETURN_END_IF POP_TOP
|
||||
and ::= expr JUMP_IF_FALSE POP_TOP expr COME_FROM
|
||||
"""
|
||||
|
||||
def customize_grammar_rules(self, tokens, customize):
|
||||
|
@@ -940,7 +940,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.prec = 27
|
||||
|
||||
# FIXME: clean this up
|
||||
if self.version > 3.0 and node == 'dict_comp':
|
||||
if self.version >= 3.0 and node == 'dict_comp':
|
||||
cn = node[1]
|
||||
elif self.version < 2.7 and node == 'generator_exp':
|
||||
if node[0] == 'LOAD_GENEXPR':
|
||||
@@ -948,7 +948,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
elif node[0] == 'load_closure':
|
||||
cn = node[1]
|
||||
|
||||
elif self.version > 3.0 and node == 'generator_exp':
|
||||
elif self.version >= 3.0 and node == 'generator_exp':
|
||||
if node[0] == 'load_genexpr':
|
||||
load_genexpr = node[0]
|
||||
elif node[1] == 'load_genexpr':
|
||||
|
Reference in New Issue
Block a user