GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-45607: Make it possible to enrich exception displays via setting their __note__ field by iritkatriel · Pull Request #29880 · python/cpython

Conversation

@iritkatriel

@iritkatriel iritkatriel commented Dec 1, 2021 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

https://bugs.python.org/issue45607

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Zac-HD and kumaraditya303 reacted with hooray emoji Zac-HD reacted with heart emoji erlend-aasland and Zac-HD reacted with rocket emoji
All reactions
  • 🎉 2 reactions
  • ❤️ 1 reaction
  • 🚀 2 reactions
iritkatriel added 6 commits December 1, 2021 11:17
@iritkatriel
bpo-45607: Add __note__ field to BaseException
78f9a9a
@iritkatriel
add test_note in test_exceptions
2f380bf
@iritkatriel
add to traceback
8ab5e13
@iritkatriel
add exception group test
c6e07e3
@iritkatriel
remove redundant assertion
5bf6edd
@iritkatriel
support multi-line notes as well. Test for empty string in note
263b753
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Dec 1, 2021
@bedevere-bot bedevere-bot added the awaiting core review label Dec 1, 2021
blurb-it Bot and others added 3 commits December 1, 2021 15:38
@blurb-it
📜🤖 Added by blurb_it.
36b6022
@iritkatriel
add to doc
35ba887
@iritkatriel
whatsnew in 3.11
85b537d
@iritkatriel
iritkatriel requested review from erlend-aasland and gvanrossum December 1, 2021 15:56
@iritkatriel

iritkatriel commented Dec 1, 2021

Copy link
Copy Markdown
Member Author

Should I add PyException_GetNote and PyException_SetNote to the c api?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iritkatriel added 3 commits December 1, 2021 15:58
@iritkatriel
backticks in doc
12ba64e
@iritkatriel
remove extra newline in test
cbb52dc
@iritkatriel
fix expected exception sizes in test_sys
8592206
erlend-aasland
erlend-aasland reviewed Dec 2, 2021
View reviewed changes

@erlend-aasland erlend-aasland left a comment

Copy link
Copy Markdown
Contributor

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.

Nice feature! LGTM. I found one path not covered by the test suite. I of course also left some pedantic PEP-7 comments 🤓

(BTW, I still find the error handling in pythonrun.c hard to read... and it generates so many indent levels 😕)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Objects/exceptions.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Objects/exceptions.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Objects/exceptions.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/traceback.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Misc/NEWS.d/next/Core and Builtins/2021-12-01-15-38-04.bpo-45607.JhuF8b.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/library/exceptions.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Objects/exceptions.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

iritkatriel and others added 5 commits December 2, 2021 10:07
@iritkatriel Erlend Egeberg Aasland
whitespace
3adba26
Co-authored-by: Erlend Egeberg Aasland <[email protected]>
@iritkatriel Erlend Egeberg Aasland
Py_NewRef
cf1c0e8
Co-authored-by: Erlend Egeberg Aasland <[email protected]>
@iritkatriel Erlend Egeberg Aasland
PEP7
32a174b
Co-authored-by: Erlend Egeberg Aasland <[email protected]>
@iritkatriel Erlend Egeberg Aasland
rst formatting
ea1b40a
Co-authored-by: Erlend Egeberg Aasland <[email protected]>
@iritkatriel
single quotes
a96c8d6
@iritkatriel

iritkatriel commented Dec 2, 2021

Copy link
Copy Markdown
Member Author

Thanks.

(BTW, I still find the error handling in pythonrun.c hard to read... and it generates so many indent levels 😕)

I'm working on it. I made a patch that changed so much it would take a year to review. I'll break it up.

erlend-aasland reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kumaraditya303
kumaraditya303 reviewed Dec 2, 2021
View reviewed changes
Comment thread Objects/exceptions.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

kumaraditya303
kumaraditya303 reviewed Dec 2, 2021
View reviewed changes
Comment thread Objects/exceptions.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel
tidy up type check for note (Kumar's review comments)
77858af
gvanrossum
gvanrossum approved these changes Dec 3, 2021
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

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.

Nice! LGTM, but please fix the issues Erlend brought up.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting core review labels Dec 3, 2021
@iritkatriel

iritkatriel commented Dec 3, 2021

Copy link
Copy Markdown
Member Author

Nice! LGTM, but please fix the issues Erlend brought up.

I did all of them except the test coverage for the error when passing NULL to the setter. This would only come into play if I add PyException_GetNote and PyException_SetNote to the C api. I think we need those, right?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented Dec 3, 2021

Copy link
Copy Markdown
Member

I did all of them except the test coverage for the error when passing NULL to the setter. This would only come into play if I add PyException_GetNote and PyException_SetNote to the C api. I think we need those, right?

I think we should not add to the C API. If people want to access the note from C, they can use the __note__ attribute (like you do in the exception-printing C code). Even so, what happens when you try del err.__note__?

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel

iritkatriel commented Dec 3, 2021

Copy link
Copy Markdown
Member Author

Ah yes, very good:

>>> del e.__note__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __note__ may not be deleted

erlend-aasland reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented Dec 3, 2021 via email

Copy link
Copy Markdown
Member
That behavior is fine. So do you have a unit test for that? If not, it should be easy to add one.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel

iritkatriel commented Dec 3, 2021

Copy link
Copy Markdown
Member Author

That behavior is fine. So do you have a unit test for that? If not, it should be easy to add one.

I don’t, I’ll add one.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iritkatriel
add del test
7a5e37e
gvanrossum
gvanrossum approved these changes Dec 3, 2021
View reviewed changes

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

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.

+1

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iritkatriel
iritkatriel merged commit 5bb7ef2 into python:main Dec 3, 2021
@bedevere-bot bedevere-bot removed the awaiting merge label Dec 3, 2021
@Zac-HD Zac-HD mentioned this pull request Dec 4, 2021
Experiment with ExceptionGroup and BaseException.add_note() (in Python 3.11) HypothesisWorks/hypothesis#3175
Closed
@iritkatriel
iritkatriel deleted the bpo-45607-exception-note branch December 8, 2021 20:09
@Zac-HD Zac-HD mentioned this pull request Dec 10, 2021
Replace MultipleFailures with ExceptionGroup on Python 3.11+ HypothesisWorks/hypothesis#3191
Closed
@lancelote lancelote mentioned this pull request Dec 20, 2021
Add __note__ to BaseException in Python 3.11 python/typeshed#6633
Merged
@iritkatriel iritkatriel mentioned this pull request Apr 10, 2022
PEP 678: Make it possible to enrich an exception's error message #89770
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@erlend-aasland erlend-aasland erlend-aasland left review comments
@kumaraditya303 kumaraditya303 kumaraditya303 left review comments
@gvanrossum gvanrossum gvanrossum approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@iritkatriel @gvanrossum @erlend-aasland @kumaraditya303 @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.