惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
Malwarebytes
Malwarebytes
C
Cybersecurity and Infrastructure Security Agency CISA
The Register - Security
The Register - Security
AWS News Blog
AWS News Blog
V
Vulnerabilities – Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Schneier on Security
F
Full Disclosure
T
Tenable Blog
I
Intezer
The Hacker News
The Hacker News
Spread Privacy
Spread Privacy
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Cyberwarzone
Cyberwarzone
F
Future of Privacy Forum
Latest news
Latest news
P
Palo Alto Networks Blog
李成银的技术随笔
U
Unit 42
人人都是产品经理
人人都是产品经理
T
ThreatConnect
P
Privacy & Cybersecurity Law Blog
Know Your Adversary
Know Your Adversary
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
月光博客
月光博客
有赞技术团队
有赞技术团队
P
Privacy International News Feed
H
Help Net Security
K
Kaspersky official blog
Blog — PlanetScale
Blog — PlanetScale
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Recorded Future
Recorded Future
爱范儿
爱范儿
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
C
Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
G
GRAHAM CLULEY
大猫的无限游戏
大猫的无限游戏
T
The Blog of Author Tim Ferriss
T
Tor Project blog
T
True Tiger Recordings
T
Threatpost
Cisco Talos Blog
Cisco Talos Blog
S
Securelist
A
About on SuperTechFans

DEV Community

Business Logic Flaws: How Attackers Skip Steps in Your App to Get What They Should Never Have Why Vibe Coders Need Boilerplates to Save Time, Tokens, and Build More Secure SaaS Projects Idle Cloud Cost Is the New Egress Cost Ghost in the Stack (Part 1): Why uninitialized variables remember old data Building a High-Performance Local Chess Assistant Extension with WebAssembly Stockfish and Manifest V3 Breaking the Trade-off Between Self-Custody and Intelligent Automation on the Stellar Network I Open-Sourced a Practical Fullstack Interview Preparation Repository (React + Node + System Design) 🚀 How I Started Coding as a Student (Beginner-Friendly Guide) WordPress vs. Ghost: Why Automated Bot Attacks Are Making us think much I tested 4 AI agent-governance tools against an open spec - here's the matrix zkML Inference Proof: What the Receipt Proves, and What the Model Still Does Not I Scored 1000/1000 on AWS Certified AI Practitioner (AIF-C01) Here's Every Resource I Used Go - Struct and Interface Handling JSON Requests in Go Storing Kamal secrets in AWS Secrets Manager and deploying to a cheap Hetzner VPS How I Caught and Fixed an N+1 Query in My Django REST API I got tired of paying $10/month to remove image backgrounds – so I built it for free How to Start Coding as a Student: A Complete Beginner’s Guide 🚀 Storing Kamal secrets in AWS Secrets Manager and deploying to a cheap Hetzner VPS What Are Buffers? Build AI Agents with Hot Dev The Client Onboarding Checklist That Prevents 90% of Project Problems Scalable Treasure Hunts Are a Myth, But We Almost Made One Gemini 3.5 Flash Has a 1M Token Context Window. Here's What You Can Actually Build With It. I built a ultra-polished developer portfolio template using React & Tailwind v4 (with zero-JSX configuration) Gemini CLI Is Dead. Here's the Better Thing That Replaced It Post-quantum cryptography for embedded and IoT: secure boot, TLS and OTA Understanding Optimistic Preloading in Modern Applications Nobody Wants to Read Your Code (And You Don't Want to Read Theirs) A clothing pairing app E2B vs E4B vs 31B Dense: The Practical Guide to Choosing the Right Gemma 4 Model I built an AI app store screenshot generator because Figma made me cry — looking for brutal feedback Hello DEV Community — My Developer Journey Begins Adaptable apps on ChromeOS: a post-mortem The WordPress Paradox: Why It’s Here to Stay (and How to Stop Ruining It) I built a local voice AI that can change to 9 different personalities! UXRay: I Built an AI That Roasts Your UI Like a Senior Designer Would Wyrly DI: Type-safe Dependency Injection for Modern TypeScript The contract is the interface: agent-driven Steampipe Stave in one command Gemma 4's Hidden Superpower: Why Built-in Thinking Tokens Change Everything for Evaluation Tasks ⚡ WordPress Performance: The Real Truth They Don't Tell You A Mobile App Usually Needs an Admin System First Customer Portals Should Remove Repeated Admin Work Episode 4: The Time Loop (Layers & Caching) I Built ContextForge with Gemma 4: A Project Memory Generator for Developers and AI Coding Agents Why shadow DOM beat iframe for inline tooltips HOW TO CREATE USER AND ASSIGN ROLES IN AZURE WITH ENTRA ID When AI Blackmail Goes Viral Episode 3: The Secret Scroll (The Dockerfile) Monte Carlo Simulation for Engineers: Turning Uncertainty Into Numbers The tokens-per-byte trap: character-level 'compression' adds tokens Nobody Reads Your Code Anymore Why I built a collection of 5 free, zero-signup career finance tools for solo builders 🚀 New React Challenge: Instant UI with useOptimistic Resolvendo a Alucinação da IA na Arquitetura de Software com Code Property Graphs e .NET 9 S1 — Clean Backtrace Crashes: How to Diagnose and Fix Them Cómo solucionar el bucle infinito en useEffect con objetos y arrays The Brutal Reality of Running Gemma 4 Locally I made Claude Code refuse to write code unless the ticket scores 80/100 I Fed React's Entire Hooks Transition History to Gemma 4. Here's What It Found That We Missed. Building a Private RAG System: Lessons from a Local-First AI Journal CodePulse AI — Reviving an AI-Powered Repository Intelligence Platform How to Split Video into Segments with FFmpeg (CLI + API) I've audited dozens of estate agency websites. The same 5 problems show up every single time. Part 1: Taming Asynchronous JavaScript: How to Build a "Mailbox" Queue Building My AI-Powered VS Code Extension 🚀 Google Login in Express with PassportJS & JWT Great example of Gemma 4 moving beyond chatbots into real-world decision support. Using AI to guide everyday actions like recycling shows how impactful applied LLMs can be when designed for usability, not just capability. #Gemma4 #AI #Sustainability Building a Production AI Chatbot for an Educational Institute: Architecture, Lessons & Full Stack Deep-Dive Google Login in Express with PassportJS & JWT How I reclaimed 47GB on my MacBook by cleaning developer project junk Operators Are Not Oracles: How We Learned to Stop Worrying and Love the Configuration I Built 6 Free Developer Tools for AI APIs, Cron, Docker, and Self-Hosting How I Built a Real-Time Precious Metals Price Feed for 30,000 Concurrent Users in Laravel How to Use a SERP API to Validate Whether a Project Idea Is Worth Building Gemma 4 discussions often focus on capability, but real-world impact depends on deployment context. For offline education, especially in low-connectivity regions, latency, cost, and local inference matter as much as model strength. Local Mind Explores it Space Complexity + Ω and Θ Notations Google I/O 2026 Just Confirmed the Shift From AI Chatbots to AI Agents How to Add API Monitoring to an Express App in 5 Minutes (2026) Designing an In-Game Inflation Tracking Algorithm for Web Utility Apps Google AI Studio Just Changed the Shape of App Development If you struggle to learn then this is for you. Best AI Agent Security & Guardrails Tools in 2026: LLM Guard vs NeMo vs Guardrails AI Building Dynamic RBAC in React 19: From Permission Strings to Component-Level Access Control How to Build a Self-Hosted AI Code Review Tool in Python Why We Switched from React to HTMX in Production: A 200-Site Case Study Gemma-Loom: The Intent-Based Virtual Machine (IVM) for Edge Sovereignty Java实习海投攻略:3天300个沟通,我是怎么拿到面试的 I Deployed Netflix's Web Server in 30 Seconds (And So Can You) - Docker Project 1 Debugging Android 14 WebRTC Disconnects on a coturn Relay Path 1/30 Days System Design Question Testing FastAPI + SQLAlchemy with Real PostgreSQL Fixtures: No More Mocking Misery FAQ Schema Markup Generators: What They Actually Do (and What They Don't Tell You) How a pure-TypeScript flex layout engine closed the last WASM-Yoga gap Spot instances as GitHub Actions runners Agents Need Receipts, Not Just Better Prompts readmegen — Generate beautiful README.md in seconds (12 templates, open source) When AI Reads Blueprints: The Hidden Attack Surface of Multimodal Engineering Intelligence Simplicity scales — complexity kills side projects AI does exactly what you ask — that's the problem
Quark's Outlines: Python Traceback Objects
Mike Vincent · 2026-05-23 · via DEV Community

Quark’s Outlines: Python Traceback Objects

Overview, Historical Timeline, Problems & Solutions

An Overview of Python Traceback Objects

What is a Python traceback object?

When you run a Python program and an error happens, Python shows you a stack trace. A stack trace shows where the error came from. It tells you what function failed and which line caused it. A Python traceback object holds that information.

Each traceback object shows one step in the chain of function calls that led to the error. Python builds this chain as it unwinds the stack. The traceback includes the function’s frame, the line number, and the bytecode instruction that failed.

Python lets you examine what went wrong using traceback objects.

import traceback

try:
    1 / 0
except ZeroDivisionError as e:
    tb = e.__traceback__
    print("Line:", tb.tb_lineno)

Enter fullscreen mode Exit fullscreen mode

This traceback shows the line where the error happened. You can follow it to see how Python reached that point.

What does a Python traceback object contain?

A traceback object stores the frame that was active at the time of the error. It also stores the line number and the last instruction run in that frame. If there were more calls before the error, the traceback links to the next earlier traceback using tb_next.

You can think of a traceback as a trail of breadcrumbs that shows how the program moved from one function to the next before it failed.

Python traceback objects form a chain of frames leading to the error.

def a():
    b()

def b():
    1 / 0

try:
    a()
except ZeroDivisionError as e:
    tb = e.__traceback__
    print("Error in:", tb.tb_frame.f_code.co_name)

Enter fullscreen mode Exit fullscreen mode

This prints the name of the function where the error happened. You can also walk backward using tb_next.


A Historical Timeline of Python Traceback Objects

Where do Python’s traceback objects come from?

Python traceback objects follow the idea of stack traces from earlier programming tools. They allow you to see what went wrong and where. This timeline shows how traceback support in Python grew over time.


People invented ways to trace error locations

1960 —Stack trace messages first appeared in debugging tools for compiled languages.

1970s —Structured error reporting became common in tools for ALGOL and Pascal.


People designed traceback support in Python

1991 —Python added exceptions and built-in stack traces for all uncaught errors.

1994 —Traceback module added to let users walk through exceptions by hand.

2000 —__traceback__ attribute added to exceptions to hold traceback objects.

2010 —Chained exceptions allowed Python to preserve traceback links across raise from.

2020 —Traceback access improved in tools like traceback.TracebackException for structured error analysis.


Problems & Solutions with Python Traceback Objects

How do you use Python traceback objects the right way?

Python traceback objects help you see where an error started, where it happened, and what Python was doing. When an error happens, Python builds a traceback. This traceback helps you trace the flow of execution and fix the problem. Each of these problems shows how to use traceback objects in real code.


Problem: How do you get the line where an error occurred in Python?

You are running some code that raises an error. You want to find the exact line number where the problem happened. You want to get that number from Python, not by reading the stack trace on screen.

Problem: You need to get the line number of the error programmatically.

Solution: Python traceback objects give the line number using tb_lineno.

Python lets you read the error line number from a traceback object.

try:
    int("nope")
except ValueError as e:
    tb = e.__traceback__
    print("Line number:", tb.tb_lineno)
# prints:
# Line number: 2

Enter fullscreen mode Exit fullscreen mode

The tb_lineno attribute gives you the exact line where Python stopped with an error.


Problem: How do you find the function where the error happened in Python?

You are debugging a complex program. You want to know which function caused the error without reading the full traceback printout.

Problem: You want the name of the function where the error occurred.

Solution: Python traceback objects include the frame, which has the code object and its name.

Python lets you get the function name from the traceback’s frame.

def crash():
    return 1 / 0

try:
    crash()
except ZeroDivisionError as e:
    tb = e.__traceback__
    print("Function:", tb.tb_frame.f_code.co_name)
# prints:
# Function: crash

Enter fullscreen mode Exit fullscreen mode

The frame tells you which function was running when the error happened.


Problem: How do you follow all the steps that led to an error in Python?

You are debugging a failure that goes through several functions. You want to walk back through all of them and see which path Python took.

Problem: You need to trace the full call stack leading to an error.

Solution: Python traceback objects form a chain using tb_next.

Python lets you walk the full traceback using tb_next.

def a():
    b()

def b():
    c()

def c():
    1 / 0

try:
    a()
except ZeroDivisionError as e:
    tb = e.__traceback__
    while tb:
        print("Function:", tb.tb_frame.f_code.co_name)
        tb = tb.tb_next
# prints:
# Function: c
# Function: b
# Function: a

Enter fullscreen mode Exit fullscreen mode

You can walk the call chain backwards from the point of error using the tb_next link.


Problem: How do you print a traceback yourself in Python?

You are writing a tool that logs errors to a file. You want to include the full stack trace, not just the error message.

Problem: You want to format and print the traceback manually.

Solution: Python has a traceback module that can format tracebacks from objects.

Python lets you print full tracebacks using the traceback module.

import traceback

try:
    open("/this/does/not/exist.txt")
except Exception as e:
    traceback.print_tb(e.__traceback__)
# prints:
#   File "example.py", line 3, in <module>
#     open("/this/does/not/exist.txt")

Enter fullscreen mode Exit fullscreen mode

This gives you a clean traceback without exiting the program.


Problem: How do you access traceback information from outside an except block in Python?

You are running code in a notebook or tool. You want to access the last traceback after the program stops. You did not save the error at the time.

Problem: You want to read the last exception traceback after the program ends.

Solution: Python keeps the last traceback in sys.last_traceback when run interactively.

Python lets you access the last traceback using the sys module.

import sys

# Only works in interactive mode:
# sys.last_traceback

Enter fullscreen mode Exit fullscreen mode

This lets you recover traceback details even if the program already stopped. It only works if Python is running in interactive mode and the error was uncaught.


Like, Comment, Share, and Subscribe

Did you find this helpful? Let me know by clicking the like button below. I'd love to hear your thoughts in the comments, too! If you want to see more content like this, don't forget to subscribe. Thanks for reading!


Mike Vincent is an American software engineer and app developer from Los Angeles, California. More about Mike Vincent