stack-data is a Python library designed to extract detailed information from stack frames and tracebacks, offering more useful and customizable displays than Python's default tracebacks. It's currently at version 0.6.3 and is actively maintained, powering features in tools like IPython and futurecoder.
Install & Compatibility
Where this runs
tested against v0.6.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.925 runs
installs and imports cleanly · install 0.0s · import 0.123s · 18.5MB
glibcpy 3.10–3.925 runs
installs and imports cleanly · install 1.7s · import 0.114s · 19MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from stack_data import FrameInfo
from stack_data import Options
from stack_data import Line
This example demonstrates basic usage by creating a FrameInfo object from the current frame and then iterating through its lines to print the source code, highlighting the current line.
import inspect
import stack_data
def foo():
result = []
for i in range(2):
row = []
result.append(row)
print_stack()
for j in range(2):
row.append(i * j)
return result
def print_stack():
frame = inspect.currentframe().f_back
frame_info = stack_data.FrameInfo(frame)
print(f"{frame_info.code.co_name} at line {frame_info.lineno}")
print("-----------")
for line in frame_info.lines:
print(f"{'-->' if line.is_current else ' '} {line.lineno:4} | {line.render()}")
foo()
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.