You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Redo uncompyel6 options ...
Use click now and make more like decompyle3
This commit is contained in:
@@ -2036,6 +2036,8 @@ def code_deparse(
|
||||
code_objects={},
|
||||
compile_mode="exec",
|
||||
walker=FragmentsWalker,
|
||||
start_offset: int = 0,
|
||||
stop_offset: int = -1,
|
||||
):
|
||||
"""
|
||||
Convert the code object co into a python source fragment.
|
||||
@@ -2070,6 +2072,22 @@ def code_deparse(
|
||||
tokens, customize = scanner.ingest(co, code_objects=code_objects, show_asm=show_asm)
|
||||
|
||||
tokens, customize = scanner.ingest(co)
|
||||
|
||||
if start_offset > 0:
|
||||
for i, t in enumerate(tokens):
|
||||
# If t.offset is a string, we want to skip this.
|
||||
if isinstance(t.offset, int) and t.offset >= start_offset:
|
||||
tokens = tokens[i:]
|
||||
break
|
||||
|
||||
if stop_offset > -1:
|
||||
for i, t in enumerate(tokens):
|
||||
# In contrast to the test for start_offset If t.offset is
|
||||
# a string, we want to extract the integer offset value.
|
||||
if t.off2int() >= stop_offset:
|
||||
tokens = tokens[:i]
|
||||
break
|
||||
|
||||
maybe_show_asm(show_asm, tokens)
|
||||
|
||||
debug_parser = dict(PARSER_DEFAULT_DEBUG)
|
||||
|
Reference in New Issue
Block a user