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-104770: Let generator.close() return value#104771

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
gvanrossum merged 9 commits intopython:mainfromntessore:generator-close-return
May 23, 2023
Merged

gh-104770: Let generator.close() return value#104771

gvanrossum merged 9 commits intopython:mainfromntessore:generator-close-return
May 23, 2023

Conversation

@ntessore
Copy link
Contributor

@ntessorentessore commentedMay 22, 2023
edited by github-actionsbot
Loading

This changeset altersgenerator.close() to return the value of aStopIteration it encounters. Conceptually, the change is simple: instead of lumpingStopIteration in withGeneratorExit and ignoring it, the exception is handled specially and its value returned.

Practically, handling the exception is a little awkward because no high-level API exists (afaict) to retrieve the value of aStopIteration. I would be happy for any pointers on how to handle this better, if possible.


📚 Documentation preview 📚:https://cpython-previews--104771.org.readthedocs.build/

@bedevere-bot
Copy link

Most changes to Pythonrequire a NEWS entry.

Please add it using theblurb_it web app or theblurb command-line tool.

@ghost
Copy link

ghost commentedMay 22, 2023
edited by ghost
Loading

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link

Most changes to Pythonrequire a NEWS entry.

Please add it using theblurb_it web app or theblurb command-line tool.

gvanrossum
gvanrossum previously requested changesMay 23, 2023
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.

I'm also asking@iritkatriel to review -- I'm not sure if poking attstate->current_exception is the right way to access the current exception. Maybe the brand newPyPyErr_GetRaisedException() is the API to use? (Then you don't even need to get the tstate).

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@ntessore
Copy link
ContributorAuthor

I have made the requested changes; please review again.

In the docs, I made the wording of the "returns return value" situation sound as natural as I could, but it might need more polishing.

I didn't know aboutPyErr_GetRaisedException(), thanks! That fits perfectly here. I don't suppose there's a brand new API to extract the value from an exception?

@bedevere-bot
Copy link

Thanks for making the requested changes!

@gvanrossum: please review the changes made to this pull request.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
@ntessore
Copy link
ContributorAuthor

Thanks@iritkatriel, that is much better. I have made the requested changes; please review again.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@gvanrossum,@iritkatriel: please review the changes made to this pull request.

@gvanrossum
Copy link
Member

I'll leave the rest of the review to Irit.

Copy link
Member

@iritkatrieliritkatriel left a comment
edited
Loading

Choose a reason for hiding this comment

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

Code looks fine, a couple of comments on documentation.

ntessoreand others added2 commitsMay 23, 2023 19:37
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
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.

Fantastic! I will merge now.

ntessore reacted with hooray emoji
@gvanrossumgvanrossum merged commitd56c933 intopython:mainMay 23, 2023
@ntessorentessore deleted the generator-close-return branchMay 23, 2023 20:53
@ntessore
Copy link
ContributorAuthor

Thanks again Irit and Guido for your help and patience!

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

Reviewers

@iritkatrieliritkatrieliritkatriel approved these changes

@gvanrossumgvanrossumgvanrossum approved these changes

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@ntessore@bedevere-bot@gvanrossum@iritkatriel

[8]ページ先頭

©2009-2025 Movatter.jp