You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Show magic number in output
Fix bugs due to removal of token.format()
This commit is contained in:
@@ -12,7 +12,7 @@ from xdis.load import load_module
|
||||
def uncompyle(
|
||||
version, co, out=None, showasm=False, showast=False,
|
||||
timestamp=None, showgrammar=False, code_objects={},
|
||||
is_pypy=False):
|
||||
is_pypy=False, magic_int=None):
|
||||
"""
|
||||
disassembles and deparses a given code block 'co'
|
||||
"""
|
||||
@@ -22,8 +22,10 @@ def uncompyle(
|
||||
real_out = out or sys.stdout
|
||||
co_pypy_str = 'PyPy ' if is_pypy else ''
|
||||
run_pypy_str = 'PyPy ' if IS_PYPY else ''
|
||||
print('# %sPython bytecode %s (disassembled from %sPython %s)\n' %
|
||||
(co_pypy_str, version, run_pypy_str, PYTHON_VERSION),
|
||||
print('# %sPython bytecode %s%s disassembled from %sPython %s' %
|
||||
(co_pypy_str, version,
|
||||
" (%d)" % magic_int if magic_int else "",
|
||||
run_pypy_str, PYTHON_VERSION),
|
||||
file=real_out)
|
||||
if co.co_filename:
|
||||
print('# Embedded file name: %s' % co.co_filename,
|
||||
@@ -60,11 +62,11 @@ def uncompyle_file(filename, outstream=None, showasm=False, showast=False,
|
||||
for con in co:
|
||||
uncompyle(version, con, outstream, showasm, showast,
|
||||
timestamp, showgrammar, code_objects=code_objects,
|
||||
is_pypy=is_pypy)
|
||||
is_pypy=is_pypy, magic_int=magic_int)
|
||||
else:
|
||||
uncompyle(version, co, outstream, showasm, showast,
|
||||
timestamp, showgrammar, code_objects=code_objects,
|
||||
is_pypy=is_pypy)
|
||||
is_pypy=is_pypy, magic_int=magic_int)
|
||||
co = None
|
||||
|
||||
# FIXME: combine into an options parameter
|
||||
|
@@ -14,7 +14,7 @@ def maybe_show_asm(showasm, tokens):
|
||||
if showasm:
|
||||
stream = showasm if hasattr(showasm, 'write') else sys.stdout
|
||||
for t in tokens:
|
||||
stream.write(t)
|
||||
stream.write(str(t))
|
||||
stream.write('\n')
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ def maybe_show_ast(showast, ast):
|
||||
"""
|
||||
if showast:
|
||||
stream = showast if hasattr(showast, 'write') else sys.stdout
|
||||
stream.write(repr(ast))
|
||||
stream.write(str(ast))
|
||||
stream.write('\n')
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user