Module: core.tbtools
2 Classes
- class IPython.core.tbtools.FrameInfo(description: str | None, filename: str, lineno: int, frame: Any, code: CodeType | None, *, sd: Any = None, context: int | None = None)
Bases:
objectMirror of stack data’s FrameInfo, but so that we can bypass highlighting on really long frames.
- class IPython.core.tbtools.TBTools(color_scheme: Any = <object object>, call_pdb: bool = False, ostream: Any = None, *, debugger_cls: type | None = None, theme_name: str = 'nocolor')
Bases:
objectBasic tools used by all traceback printer classes.
- __init__(color_scheme: Any = <object object>, call_pdb: bool = False, ostream: Any = None, *, debugger_cls: type | None = None, theme_name: str = 'nocolor')
- property ostream: Any
Output stream that exceptions are written to.
Valid values are:
None: the default, which means that IPython will dynamically resolve to sys.stdout. This ensures compatibility with most tools, including Windows (where plain stdout doesn’t recognize ANSI escapes).
Any object with ‘write’ and ‘flush’ attributes.
- structured_traceback(etype: type, evalue: BaseException | None, etb: TracebackType | None = None, tb_offset: int | None = None, context: int = 5) list[str]
Return a list of traceback frames.
Must be implemented by each class.
- text(etype: type, value: BaseException | None, tb: TracebackType | None, tb_offset: int | None = None, context: int = 5) str
Return formatted traceback.
Subclasses may override this if they add extra arguments.
5 Functions
- IPython.core.tbtools.count_lines_in_py_file(filename: str) int
Given a filename, returns the number of lines in the file if it ends with the extension “.py”. Otherwise, returns 0.
- IPython.core.tbtools.get_line_number_of_frame(frame: FrameType) int
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 be determined.
- 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.
- Return type: