Skip to content

Commit

Permalink
PEP 678: add post-history, minor tweaks following discussion (#2294)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD authored Feb 3, 2022
1 parent 73fbc86 commit 6d1703c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pep-0678.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ PEP: 678
Title: Enriching Exceptions with Notes
Author: Zac Hatfield-Dodds <[email protected]>
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
Expand Down Expand Up @@ -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>`__
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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/
Expand Down

0 comments on commit 6d1703c

Please sign in to comment.