pub struct StackFrame {
pub filename: String,
pub start: CodeLoc,
pub end: CodeLoc,
pub frame_name: Option<String>,
pub preview_line: Option<Arc<str>>,
pub hide_caret: bool,
pub hide_frame_name: bool,
}Expand description
A single frame in a Python traceback.
Contains all the information needed to display a traceback line: the file location, function name, and optional source code preview.
§Caret Markers
Monty uses only ~ characters for caret markers in tracebacks, unlike CPython 3.11+
which uses ~ for the function name and ^ for arguments (e.g., ~~~~~~~~~~~^^^^^^^^^^^).
This simplification is intentional - Monty marks the entire expression span uniformly.
Fields§
§filename: StringThe filename where the code is located.
start: CodeLocStart position in the source code.
end: CodeLocEnd position in the source code.
frame_name: Option<String>The name of the frame (function name, or None for module-level code).
preview_line: Option<Arc<str>>The source code line for preview in the traceback.
Stored as Arc<str> rather than String so that consecutive frames
referencing the same source line — typical of recursion and tight
helper-function loops — share a single allocation. Without sharing, a
1000-deep recursive call into code on a long line would clone the
entire line into each frame and amplify memory usage by the call
depth. Serialization roundtrips lose the sharing (each frame gets
its own Arc), but that is bounded by the wire size of the
traceback so does not regress the amplification.
hide_caret: boolWhether to hide the caret marker in the traceback for this frame.
Set to true for:
raisestatements (CPython doesn’t show carets for raise)AttributeErroron attribute access (CPython doesn’t show carets for these)
hide_frame_name: boolWhether to hide the , in <name> part of the frame line.
Set to true for SyntaxError where CPython doesn’t show the frame name.
CPython’s SyntaxError format: File "...", line N
vs runtime error format: File "...", line N, in <module>
Trait Implementations§
Source§impl Clone for StackFrame
impl Clone for StackFrame
Source§fn clone(&self) -> StackFrame
fn clone(&self) -> StackFrame
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more