Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PEP 9999: Add timestamps to exception tracebacks #4592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
gpshead wants to merge 4 commits into python:main
base: main
Choose a base branch
Loading
from gpshead:pep-exception-timestamps

Conversation

@gpshead
Copy link
Member

@gpshead gpshead commented Sep 17, 2025
edited
Loading

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /