diff --git a/uncompyle6/main.py b/uncompyle6/main.py index 383d2061..f7c48e13 100644 --- a/uncompyle6/main.py +++ b/uncompyle6/main.py @@ -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 diff --git a/uncompyle6/show.py b/uncompyle6/show.py index 381276f4..58cce4c7 100644 --- a/uncompyle6/show.py +++ b/uncompyle6/show.py @@ -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')