MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / dis

Function dis

tools/python-3.11.9-amd64/Lib/dis.py:68–111  ·  view source on GitHub ↗

Disassemble classes, methods, functions, and other compiled objects. With no argument, disassemble the last traceback. Compiled objects currently include generator objects, async generator objects, and coroutine objects, all of which store their code object in a special attri

(x=None, *, file=None, depth=None, show_caches=False, adaptive=False)

Source from the content-addressed store, hash-verified

66 return c
67
68def dis(x=None, *, file=None, depth=None, show_caches=False, adaptive=False):
69 """Disassemble classes, methods, functions, and other compiled objects.
70
71 With no argument, disassemble the last traceback.
72
73 Compiled objects currently include generator objects, async generator
74 objects, and coroutine objects, all of which store their code object
75 in a special attribute.
76 """
77 if x is None:
78 distb(file=file, show_caches=show_caches, adaptive=adaptive)
79 return
80 # Extract functions from methods.
81 if hasattr(x, '__func__'):
82 x = x.__func__
83 # Extract compiled code objects from...
84 if hasattr(x, '__code__'): # ...a function, or
85 x = x.__code__
86 elif hasattr(x, 'gi_code'): #...a generator object, or
87 x = x.gi_code
88 elif hasattr(x, 'ag_code'): #...an asynchronous generator object, or
89 x = x.ag_code
90 elif hasattr(x, 'cr_code'): #...a coroutine.
91 x = x.cr_code
92 # Perform the disassembly.
93 if hasattr(x, '__dict__'): # Class or module
94 items = sorted(x.__dict__.items())
95 for name, x1 in items:
96 if isinstance(x1, _have_code):
97 print("Disassembly of %s:" % name, file=file)
98 try:
99 dis(x1, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
100 except TypeError as msg:
101 print("Sorry:", msg, file=file)
102 print(file=file)
103 elif hasattr(x, 'co_code'): # Code object
104 _disassemble_recursive(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
105 elif isinstance(x, (bytes, bytearray)): # Raw bytecode
106 _disassemble_bytes(x, file=file, show_caches=show_caches)
107 elif isinstance(x, str): # Source code
108 _disassemble_str(x, file=file, depth=depth, show_caches=show_caches, adaptive=adaptive)
109 else:
110 raise TypeError("don't know how to disassemble %s objects" %
111 type(x).__name__)
112
113def distb(tb=None, *, file=None, show_caches=False, adaptive=False):
114 """Disassemble a traceback (default: last traceback)."""

Callers 1

mainFunction · 0.70

Calls 8

distbFunction · 0.85
sortedFunction · 0.85
_disassemble_recursiveFunction · 0.85
_disassemble_bytesFunction · 0.85
_disassemble_strFunction · 0.85
printFunction · 0.50
typeClass · 0.50
itemsMethod · 0.45

Tested by

no test coverage detected