MCPcopy Index your code
hub / github.com/python/cpython / _try_compile

Function _try_compile

Lib/dis.py:73–84  ·  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

71}
72
73def _try_compile(source, name):
74 """Attempts to compile the given source, first as an expression and
75 then as a statement if the first approach fails.
76
77 Utility function to accept strings in functions that otherwise
78 expect code objects
79 """
80 try:
81 return compile(source, name, 'eval')
82 except SyntaxError:
83 pass
84 return compile(source, name, 'exec')
85
86def dis(x=None, *, file=None, depth=None, show_caches=False, adaptive=False,
87 show_offsets=False, show_positions=False):

Callers 2

_get_code_objectFunction · 0.85
_disassemble_strFunction · 0.85

Calls 1

compileFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…