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

Method current_line_num

Tools/gdb/libpython.py:1203–1220  ·  view source on GitHub ↗

Get current line number as an integer (1-based) Translated from PyFrame_GetLineNumber and PyCode_Addr2Line See Objects/lnotab_notes.txt

(self)

Source from the content-addressed store, hash-verified

1201 return self.co_filename.proxyval(set())
1202
1203 def current_line_num(self):
1204 '''Get current line number as an integer (1-based)
1205
1206 Translated from PyFrame_GetLineNumber and PyCode_Addr2Line
1207
1208 See Objects/lnotab_notes.txt
1209 '''
1210 if self.is_optimized_out():
1211 return None
1212 try:
1213 return self.co.addr2line(self.f_lasti)
1214 except Exception as ex:
1215 # bpo-34989: addr2line() is a complex function, it can fail in many
1216 # ways. For example, it fails with a TypeError on "FakeRepr" if
1217 # gdb fails to load debug symbols. Use a catch-all "except
1218 # Exception" to make the whole function safe. The caller has to
1219 # handle None anyway for optimized Python.
1220 return None
1221
1222 def current_line(self):
1223 '''Get the text of the current source line as a string, with a trailing

Callers 5

current_lineMethod · 0.95
write_reprMethod · 0.95
print_tracebackMethod · 0.95
current_line_numMethod · 0.45
invokeMethod · 0.45

Calls 2

is_optimized_outMethod · 0.95
addr2lineMethod · 0.80

Tested by

no test coverage detected