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

Function find_function

tools/python-3.11.9-amd64/Lib/pdb.py:97–108  ·  view source on GitHub ↗
(funcname, filename)

Source from the content-addressed store, hash-verified

95 "post_mortem", "help"]
96
97def find_function(funcname, filename):
98 cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname))
99 try:
100 fp = tokenize.open(filename)
101 except OSError:
102 return None
103 # consumer of this info expects the first line to be 1
104 with fp:
105 for lineno, line in enumerate(fp, start=1):
106 if cre.match(line):
107 return funcname, filename, lineno
108 return None
109
110def lasti2lineno(code, lasti):
111 linestarts = list(dis.findlinestarts(code))

Callers 1

lineinfoMethod · 0.85

Calls 5

enumerateFunction · 0.85
compileMethod · 0.45
escapeMethod · 0.45
openMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected