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

Function find_first_executable_line

Lib/pdb.py:119–134  ·  view source on GitHub ↗

Try to find the first executable line of the code object. Equivalently, find the line number of the instruction that's after RESUME Return code.co_firstlineno if no executable line is found.

(code)

Source from the content-addressed store, hash-verified

117
118
119def find_first_executable_line(code):
120 """ Try to find the first executable line of the code object.
121
122 Equivalently, find the line number of the instruction that's
123 after RESUME
124
125 Return code.co_firstlineno if no executable line is found.
126 """
127 prev = None
128 for instr in dis.get_instructions(code):
129 if prev is not None and prev.opname == 'RESUME':
130 if instr.positions.lineno is not None:
131 return instr.positions.lineno
132 return code.co_firstlineno
133 prev = instr
134 return code.co_firstlineno
135
136def find_function(funcname, filename):
137 cre = re.compile(r'(?:async\s+)?def\s+%s(\s*\[.+\])?\s*[(]' % re.escape(funcname))

Callers 2

find_functionFunction · 0.85
do_breakMethod · 0.85

Calls 1

get_instructionsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…