Skip to content
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

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

Merged
merged 3 commits into from
Feb 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <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
Copy link
Member

@CAM-Gerlach CAM-Gerlach Feb 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no formal requirement I can find in PEP-0001, but less than a week of discussion and review between announcing/opening a discussion thread for a PEP and submitting it for final consideration for the SC seems a little short, at least to me...



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