traceback

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package traceback ports cpython/Python/traceback.c. v0.3 ships the data shape, the format/print entry points, and a minimal frameless builder used by the errors package to attach traceback rows from Go call sites. Real frames join in v0.6 once the VM lands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(tb *Traceback) string

Format returns the multi-line traceback string, oldest entry first. Mirrors traceback.format_tb output.

CPython: Python/traceback.c:L985 _PyTraceBack_FromFrame

func FormatException

func FormatException(tb *Traceback, typeName, message string) string

FormatException prepends typeName: message to a Format(tb) output, matching `traceback.format_exception` for a single (no-chain) exception. The errors package walks the cause/context chain itself and calls FormatException per node.

CPython: Python/traceback.c:L1129 _PyTraceBack_Print

Types

type Entry

type Entry struct {
	File string
	Line int
	Name string
}

Entry is one line of a traceback. Mirrors the data carried by PyTracebackObject (filename, line number, function name).

CPython: Objects/frameobject.h (analog) and Python/traceback.c

type Traceback

type Traceback struct {
	Entry Entry
	Next  *Traceback
}

Traceback is the linked list of entries that backs Python's `__traceback__`. The next pointer chains older frames; CPython stores the chain in reverse, with the newest frame at the head.

CPython: Include/cpython/traceback.h:L9 PyTracebackObject

func New

func New(entry Entry) *Traceback

New builds a single-entry traceback. The errors package uses this when v0.3 runtime code wants to attach a position from Go.

CPython: Python/traceback.c:L154 PyTraceBack_Here

func Push

func Push(tb *Traceback, entry Entry) *Traceback

Push prepends a new entry. The result becomes the new head.

CPython: Python/traceback.c:L154 PyTraceBack_Here

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL