-
Notifications
You must be signed in to change notification settings - Fork 20
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: new API for add_note() #4
Conversation
1e95fbc
to
62db279
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a changelog entry and we're good.
I take it that the py3.11 tests will start working with the next alpha release?
Yep, should do. If you want to hold off on merging until then that's fine by me. |
If you compile the latest version from |
It's currently on the Steering Council agenda and in python/cpython#31317, so holding this PR until the PEP is accepted or a 3.11 alpha released with the new API would make me more comfortable. And again, I'm sorry for the churn! The "how can you provide localization and translation for notes" discussion thread - which prompted these changes - came up the day after I first sent this to the SC for consideration 😓 |
Sure, let's wait until then. |
for more information, see https://pre-commit.ci
PEP-678 has formally been accepted (🥳), and I've updated this PR accordingly with the final design. Once python/cpython#31317 is merged upstream, I'll confirm that the 3.11 tests pass on CPython |
Having drafted the Hypothesis PR I'll want to use this in, I'm also planning to add a helper function def add_note(exc: BaseException, note: str) -> None:
try:
exc.add_note(note)
except AttributeError:
if not isinstance(note, str):
raise TypeError(f"Note must be a string, got {type(note).__name__}")
if not hasattr(exc, "__notes__"):
exc.__notes__ = []
exc.__notes__.append(note) on the basis that either we ship it in the backport, or literally everyone who wants to use PEP-678 notes will have to implement it for themselves. |
Have you confirmed that this PR passes against CPython 3.11 main? If so, then I'll merge. |
It seems to work, though I wanted to confirm that everything plays well together over the weekend before asking you to merge and release - apologies for the delay, but I was asked to present a tutorial at PyCon next week and that's been a fairly urgent call on my OSS time. |
@agronholm - I've retested everything against CPython nightly locally, and it's ready to merge 🚀 Thanks again for your patience! |
Thanks! |
Nice! Ping me when you release on PyPI? |
Done. |
Awesome! |
Just after my last PR - and after we'd asked the Steering Council to consider the PEP - we had some translation-related concerns that ended up prompting a slight redesign. So here's another PR with the new interface!
(and I'm sorry for the churn! Thanks for maintaining the backport 💖)