Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-89770: Implement PEP-678 - Exception notes#31317

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
iritkatriel merged 23 commits intopython:mainfromiritkatriel:pep-678
Apr 16, 2022

Conversation

iritkatriel
Copy link
Member

@iritkatrieliritkatriel commentedFeb 13, 2022
edited
Loading

No description provided.

@iritkatrieliritkatriel marked this pull request as draftFebruary 13, 2022 21:45
@iritkatrieliritkatriel added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelFeb 13, 2022
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@iritkatriel for commit1555087 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelFeb 13, 2022
@iritkatrieliritkatriel changed the titlePEP-678: exception notes are set by add_note(). __notes__ holds a tuple of the assigned notesPEP-678: implementation of exception notes as per PEP discussionsMar 16, 2022
Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

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

Where's the descriptor for"__notes__"?

Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

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

"Errors should never pass silently."

@gvanrossum
Copy link
Member

Yeah, I like this!

@iritkatriel
Copy link
MemberAuthor

How about error handling when printing the traceback? Should we print something like "cannot printnotes: not a sequence", and similarly if a note is not a str?

@gvanrossum
Copy link
Member

How about error handling when printing the traceback? Should we print something like "cannot printnotes: not a sequence", and similarly if a note is not a str?

How about printingrepr(self.__notes__) if it's not a list, andstr(note) if an individual note isn't a string? The former makes it clear what itis, while the latter provides a feature that Barry has been asking for...

If either of those fails, either raise an exception fromprint_exception() or swallow the error and print a simple message. It probably doesn't really matter,repr() orstr() failing should be extremely obscure.

Zac-HD reacted with thumbs up emoji

@iritkatriel
Copy link
MemberAuthor

How about error handling when printing the traceback? Should we print something like "cannot printnotes: not a sequence", and similarly if a note is not a str?

How about printingrepr(self.__notes__) if it's not a list, andstr(note) if an individual note isn't a string? The former makes it clear what itis, while the latter provides a feature that Barry has been asking for...

If either of those fails, either raise an exception fromprint_exception() or swallow the error and print a simple message. It probably doesn't really matter,repr() orstr() failing should be extremely obscure.

I'll do something likewhat we do for str(exc).

Zac-HD and gvanrossum reacted with thumbs up emoji

@Zac-HD
Copy link
Contributor

Heya - I think we should have an explicit test that if you.split() anExceptionGroup which already has__notes__, it's shallow-copied rather than simply assigned to the new instances. It'd be pretty confusing to call.add_note() on one and have it added to other instances too!

iritkatriel reacted with thumbs up emoji

@iritkatriel
Copy link
MemberAuthor

Heya - I think we should have an explicit test that if you.split() anExceptionGroup which already has__notes__, it's shallow-copied rather than simply assigned to the new instances. It'd be pretty confusing to call.add_note() on one and have it added to other instances too!

That's a good point. I added the test and fixed the code to copy the notes in split(), so long as they are a sequence (producing a list). If people assign arbitrary objects to notes I don't know how to copy them.
Is there a "copy protocol" we can demand?

@iritkatrieliritkatriel marked this pull request as ready for reviewApril 12, 2022 12:05
@iritkatrieliritkatriel changed the titlegh-91479: Implement PEP-678 - Exception notesbpo-45607: Implement PEP-678 - Exception notesApr 12, 2022
@iritkatrieliritkatriel changed the titlebpo-45607: Implement PEP-678 - Exception notesgh-89770: Implement PEP-678 - Exception notesApr 12, 2022
@iritkatrieliritkatriel added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 14, 2022
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@iritkatriel for commit95be670 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 14, 2022
@iritkatriel
Copy link
MemberAuthor

Sorry about the noise (I messed it up multitasking). Getting there now.

Zac-HD reacted with heart emoji

@iritkatrieliritkatriel added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 14, 2022
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@iritkatriel for commit602b4c4 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 14, 2022
@iritkatriel
Copy link
MemberAuthor

The buildbots are happy with this. Let me know if you would like to re-review, otherwise I'll merge it tomorrow or so.

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Opened#106033.

return NULL;
}

if (!PyObject_HasAttr(self, &_Py_ID(__notes__))) {

Choose a reason for hiding this comment

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

Do not use PyObject_HasAttr. It is broken by design.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@encukouencukouencukou left review comments

@gvanrossumgvanrossumgvanrossum left review comments

@serhiy-storchakaserhiy-storchakaserhiy-storchaka left review comments

@Zac-HDZac-HDZac-HD left review comments

@gpsheadgpsheadAwaiting requested review from gpshead

@pablogsalpablogsalAwaiting requested review from pablogsal

@kumaraditya303kumaraditya303Awaiting requested review from kumaraditya303

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

8 participants
@iritkatriel@bedevere-bot@gvanrossum@Zac-HD@JelleZijlstra@encukou@serhiy-storchaka@the-knights-who-say-ni

[8]ページ先頭

©2009-2025 Movatter.jp