Commit 557f24e
PEP 830: round 2 edits (#4928)
* PEP 830: Clarifications and format simplification from discussion feedback
- Clarified that __timestamp_ns__ is UTC, that clock-read failure yields 0,
and how free-list and singleton MemoryError instances are timestamped.
- Clarified that str(exc) and repr(exc) are unchanged, and that the iso
display format has microsecond resolution.
- Changed the ns display format from an integer with an ns suffix to seconds
with nine decimal digits, allowing direct use with datetime.fromtimestamp().
Dropped the us format; ns is now the default format when the feature is
enabled via 1 or with no explicit format value.
- Added Rejected Ideas entries for returning None when unset and for using a
coarse-resolution clock.
- Made the Motivation example self-contained.
* PEP 830: Reword Runtime API rejection
Frame it as an operator-level setting and note that runtime configurability
can be added later if there is demand.
* PEP 830: Add Traceback header placement rejection and Open Issues section
Explain why the timestamp is appended to the message line rather than the
Traceback header (the header is absent for exceptions without a traceback,
as with ProcessPoolExecutor's _RemoteTraceback), and add an Open Issues
section noting display location remains open to revision.
* PEP 830: Replace no_timestamp with tri-state timestamps parameter
Rename the traceback formatting parameter from no_timestamp (a
double-negative boolean) to timestamps, and make it tri-state: None follows
the global configuration (default), False suppresses, True displays any
non-zero __timestamp_ns__ regardless of the global setting.
* PEP 830: Note hasattr/getattr/dict-miss paths need no special handling
CPython's PyObject_GetOptionalAttr and the suppress paths in generic
attribute lookup already return "not found" without instantiating an
exception object, and the dict miss paths never create a KeyError
internally, so these idioms do not need to be excluded from timestamp
collection.
* PEP 830: Add sys.excepthook to Rejected Ideas
The hook fires at display time, once for the whole ExceptionGroup, so it
cannot record per-sub-exception creation times; caught exceptions never
reach it.
* PEP 830: Add instantiation vs. raise time rationale
Explain why the timestamp is recorded at instantiation rather than raise:
the two coincide in the common case, instantiation time is the more useful
value for re-raise and collect-then-group patterns, and instantiation has a
clean two-point funnel in CPython while raising does not. Defer "time of
first raise" to Open Issues.
* PEP 830: Add sys.monitoring to Rejected Ideas
Describe a viable third-party design using a RAISE callback and its costs:
per-frame (not per-exception) dispatch through vectorcall, instance dict and
PyLongObject (or list and string for add_note) allocation on every raise,
consuming a tool ID, and needing excepthook or a traceback monkeypatch to
display the attribute variant. Also describe a hybrid that keeps the struct
field and traceback display but uses monitoring for collection. Leave a
short Open Issues entry offering to prototype and benchmark if there is
demand.
* PEP 830: Editorial pass on round-2 additions
Break up two adjacent "rather than" pairs (Rationale and sys.monitoring
paragraphs) and reorder/consolidate the Change History bullets so spec
changes lead, followed by Rationale, a single Rejected Ideas bullet, a
single Open Issues bullet, and housekeeping.
* PEP 830: Rework Motivation example to actually produce multiple errors
The original TaskGroup example only ever produced one sub-exception because
TaskGroup cancels siblings on first failure. Switch to a three-backend
asyncio.gather(..., return_exceptions=True) pattern that collects every
failure, and replace the illustrative output with real output captured from
the reference implementation. Update the sys.excepthook rejection to drop
the now-stale TaskGroup reference.
* PEP 830: Tighten three Rejected Ideas / Open Issues entries
Shorten the None-when-unset and coarse-clock rejections, and replace the
"can be added later" closer in the time-of-first-raise open issue with a
note that early-construction patterns are not common in practice.
* PEP 830: Add round-2 discussion link to Post-History
* wording
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
* specific times in the example descriptions
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
---------
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>1 parent 6123044 commit 557f24e
1 file changed
Lines changed: 295 additions & 77 deletions
0 commit comments