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]
|
|
Optional[Anchor]
|
|
__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 |
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
|
|
bool
|
|
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 |
7
|
Returns:
Type | Description |
---|---|
Iterable[FrameInfo]
|
Iterable of FrameInfo, starting from top of the |
Iterable[FrameInfo]
|
stack (current code position). |