MCPcopy Index your code
hub / github.com/ipython/ipython / get_line_number_of_frame

Function get_line_number_of_frame

IPython/core/tbtools.py:41–64  ·  view source on GitHub ↗

Given a frame object, returns the total number of lines in the file containing the frame's code object, or the number of lines in the frame's source code if the file is not available. Parameters ---------- frame : FrameType The frame object whose line number is to b

(frame: types.FrameType)

Source from the content-addressed store, hash-verified

39
40
41def get_line_number_of_frame(frame: types.FrameType) -> int:
42 """
43 Given a frame object, returns the total number of lines in the file
44 containing the frame's code object, or the number of lines in the
45 frame's source code if the file is not available.
46
47 Parameters
48 ----------
49 frame : FrameType
50 The frame object whose line number is to be determined.
51
52 Returns
53 -------
54 int
55 The total number of lines in the file containing the frame's
56 code object, or the number of lines in the frame's source code
57 if the file is not available.
58 """
59 filename = frame.f_code.co_filename
60 if filename is None:
61 print("No file....")
62 lines, first = inspect.getsourcelines(frame)
63 return first + len(lines)
64 return count_lines_in_py_file(filename)
65
66
67def _safe_string(value: Any, what: Any, func: Any = str) -> str:

Callers 2

get_recordsMethod · 0.85
get_recordsMethod · 0.85

Calls 2

count_lines_in_py_fileFunction · 0.85
getsourcelinesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…