PEP 678: add post-history, minor tweaks following discussion (#2294)

This commit is contained in:
Zac Hatfield-Dodds 2022-02-03 02:37:16 -08:00 committed by GitHub
parent 73fbc86311
commit 6d1703cbe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -2,13 +2,14 @@ PEP: 678
Title: Enriching Exceptions with Notes
Author: Zac Hatfield-Dodds <zac@zhd.dev>
Sponsor: Irit Katriel
Discussions-To: https://discuss.python.org/t/pep-678-enriching-exceptions-with-notes/13374
Status: Draft
Type: Standards Track
Content-Type: text/x-rst
Requires: 654
Created: 20-Dec-2021
Python-Version: 3.11
Post-History:
Post-History: 2022-01-27
Abstract
@ -111,7 +112,7 @@ exception includes a note of the minimal failing example::
Non-goals
---------
``__note__`` is *not* intended to carry structured data. If your note is for use by
a program rather than display to a human, we recommend instead choosing a convention
a program rather than display to a human, we recommend instead (or additionally) choosing a convention
for an attribute like e.g. ``err._parse_errors = ...`` on the error or ``ExceptionGroup`` [1]_ [2]_
As a rule of thumb, prefer `exception chaining <https://docs.python.org/3/tutorial/errors.html#exception-chaining>`__
@ -276,10 +277,14 @@ to include other objects is fully backwards-compatible. In the absence of any p
use-case (see also `Non-goals`_), we prefer to begin with a restrictive API that can
be relaxed later.
We also note that converting an object to a string may raise an exception. It's more helpful
for the traceback to point to the location where the note is attached to the exception,
rather than where the exception and note are being formatted for display after propagation.
Add a helper function ``contextlib.add_exc_note()``
---------------------------------------------------
It was suggested that we add a utility such as the one below to the standard
It was suggested [11]_ that we add a utility such as the one below to the standard
library. We are open to this idea, but do not see it as a core part of the
proposal of this PEP as it can be added as an enhancement later.
@ -323,6 +328,7 @@ References
.. [8] https://github.com/python/cpython/pull/28569#discussion_r721768348
.. [9] https://bugs.python.org/issue45607
.. [10] https://github.com/python/cpython/blob/69ef1b59983065ddb0b712dac3b04107c5059735/Lib/http/client.py#L596-L597
.. [11] https://www.reddit.com/r/Python/comments/rmrvxv/pep_678_enriching_exceptions_with_notes/hptbul1/