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

Method get_records

IPython/core/doctb.py:325–366  ·  view source on GitHub ↗
(self, etb: TracebackType, context: int, tb_offset: int)

Source from the content-addressed store, hash-verified

323 return [[head] + frames + formatted_exception]
324
325 def get_records(self, etb: TracebackType, context: int, tb_offset: int) -> Any:
326 assert context == 1, context
327 assert etb is not None
328 context = context - 1
329 after = context // 2
330 before = context - after
331 if self.has_colors:
332 base_style = theme_table[self._theme_name].as_pygments_style()
333 style = stack_data.style_with_executing_node(base_style, self.tb_highlight)
334 formatter = Terminal256Formatter(style=style)
335 else:
336 formatter = None
337 options = stack_data.Options(
338 before=before,
339 after=after,
340 pygments_formatter=formatter,
341 )
342
343 # Let's estimate the amount of code we will have to parse/highlight.
344 cf: Optional[TracebackType] = etb
345 max_len = 0
346 tbs = []
347 while cf is not None:
348 try:
349 mod = inspect.getmodule(cf.tb_frame)
350 if mod is not None:
351 mod_name = mod.__name__
352 root_name, *_ = mod_name.split(".")
353 if root_name == "IPython":
354 cf = cf.tb_next
355 continue
356 max_len = get_line_number_of_frame(cf.tb_frame)
357
358 except OSError:
359 max_len = 0
360 max_len = max(max_len, max_len)
361 tbs.append(cf)
362 cf = getattr(cf, "tb_next", None)
363
364 res = list(stack_data.FrameInfo.stack_data(etb, options=options))[tb_offset:]
365 res2 = [FrameInfo._from_stack_data_FrameInfo(r) for r in res]
366 return res2
367
368 def structured_traceback(
369 self,

Callers 1

Calls 3

get_line_number_of_frameFunction · 0.85
as_pygments_styleMethod · 0.80

Tested by

no test coverage detected