Skip to content

gufo.err.frame

FrameInfo structure.

__get_anchor(segment, indent=0)

Split code segment and try to get error anchors.

Backport from Python 3.11 _extract_caret_anchors_from_line_segment.

Parameters:

Name Type Description Default
segment str

Code segment with current op.

required
indent int

Position offset.

0

Returns:

Type Description
Optional[Anchor]
  • Anchor instance if code can be refined.
Optional[Anchor]
  • None otherwise

__get_code_position(code, inst_index, line)

Extract code range for current instruction.

Parameters:

Name Type Description Default
code CodeType

Code object

required
inst_index int

Current instruction index, usually from tb_lasti

required
line str

Current code line

required

Returns:

Type Description
Optional[CodePosition]

Optional CodePosition instance

__has_code_position()

Check if python supports exact code positions.

Returns:

Type Description
bool
  • True - if python 3.11+ and PYTHONNODEBUGRANGES is not set.
bool
  • False - otherwise

exc_traceback()

Cast type to sys.exc_info().

Extract and return top-level excecution frame from current exception context.

Returns:

Type Description
TracebackType

Top-level exception frame.

iter_frames(tb, context_lines=7)

Iterate over traceback frames.

Parameters:

Name Type Description Default
tb TracebackType

current execution frame.

required
context_lines int

Source code context to extract. Current line, up to context_lines below the current line, and up to context_lines above the current line will be extracted.

7

Returns:

Type Description
Iterable[FrameInfo]

Iterable of FrameInfo, starting from top of the

Iterable[FrameInfo]

stack (current code position).