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

Function _try_compile

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

Attempts to compile the given source, first as an expression and then as a statement if the first approach fails. Utility function to accept strings in functions that otherwise expect code objects

(source, name)

Source from the content-addressed store, hash-verified

53}
54
55def _try_compile(source, name):
56 """Attempts to compile the given source, first as an expression and
57 then as a statement if the first approach fails.
58
59 Utility function to accept strings in functions that otherwise
60 expect code objects
61 """
62 try:
63 c = compile(source, name, 'eval')
64 except SyntaxError:
65 c = compile(source, name, 'exec')
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.

Callers 2

_get_code_objectFunction · 0.85
_disassemble_strFunction · 0.85

Calls 1

compileFunction · 0.70

Tested by

no test coverage detected