Skip to content

Conversation

gpshead
Copy link
Member

@gpshead gpshead commented Sep 17, 2025

This draft PEP proposes adding optional timestamps to Python exception objects that can be displayed in tracebacks. Based on CPython PR #129337 by Gregory P. Smith.

The feature adds a __timestamp_ns__ attribute to BaseException and allows configuration via environment variables or command-line options. This is particularly useful for debugging async applications with exception groups and distributed systems.

🤖 Generated with Claude Code (https://claude.ai/code)

[to be discussed at the ongoing cambridge core team sprint. discussed in room, now to go get some better motivation description and start a discuss thread to flesh this out] -gpshead


📚 Documentation preview 📚: https://pep-previews--4592.org.readthedocs.build/

This draft PEP proposes adding optional timestamps to Python exception objects that can be displayed in tracebacks. Based on CPython PR #129337 by Gregory P. Smith. The feature adds a __timestamp_ns__ attribute to BaseException and allows configuration via environment variables or command-line options. This is particularly useful for debugging async applications with exception groups and distributed systems. 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
@AA-Turner AA-Turner changed the title PEP-8XX: Add timestamps to exception tracebacks PEP 8XX: Add timestamps to exception tracebacks Sep 17, 2025
@AA-Turner AA-Turner changed the title PEP 8XX: Add timestamps to exception tracebacks PEP 9999: Add timestamps to exception tracebacks Sep 17, 2025
Added two important open issues to the PEP: 1. Whether to always collect timestamps unconditionally (performance testing shows it's cheap) and the implications for pickle size and cross-version compatibility testing 2. Configuration of control flow exception exclusions (StopIteration, AsyncStopIteration) and whether subclasses should be included, noting the performance constraints of the hot path 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
@gpshead gpshead changed the title PEP 9999: Add timestamps to exception tracebacks PEP 8XX: Add timestamps to exception tracebacks Sep 17, 2025
@gpshead gpshead changed the title PEP 8XX: Add timestamps to exception tracebacks PEP 9999: Add timestamps to exception tracebacks Sep 17, 2025
gpshead and others added 2 commits September 18, 2025 15:18
Added two new sections to address questions raised at core team sprint: 1. "Why Exception Groups Need Timestamps" - Explains that while exception groups are conceptually unrelated, in practice they have important temporal relationships for debugging causality, performance analysis, and correlation with external observability tools. 2. "Why Not Use .add_note() When Catching?" - Details six key drawbacks of using add_note() instead: not all exceptions are caught, timing accuracy issues, inconsistent application, performance overhead, complexity burden, and loss of original timing information. Key insight: When an exception occurs is intrinsic, immutable information that should be captured at the source, not added later by consumers. 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
… need Based on feedback from @picnixz about Sphinx's Skip exception and other projects using exceptions for control flow: 1. Renamed "Special Cases" to "Control Flow Exceptions" for clarity 2. Added acknowledgment that other projects need this configurability 3. Deferred specific API design to open issues 4. Updated Open Issue python#5 with key challenges: - API design options (env var vs Python API) - Performance constraints in the hot path - Subclass handling complexity - Whether to expand the default exclusion list The PEP now acknowledges the need for configurability while leaving the specific implementation approach as an open question requiring careful API design and performance testing. 🤖 Generated with Claude Code (https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant