Skip to content

Docs: Clarify generator.close() behavior regarding GeneratorExit #135819

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

Closed

Conversation

suryansh18saxena
Copy link

@suryansh18saxena suryansh18saxena commented Jun 22, 2025

gh-135110: Clarify that generator.close() does not externally raise GeneratorExit

Where: gh-135110 refers to the GitHub issue number being fixed.

This change addresses a documentation inconsistency where it was previously implied that generator.close() raises a GeneratorExit externally. However, this exception is raised inside the generator at the suspension point, and if not handled, it fails silently without propagating.

This change helps new users clearly understand how close() behaves when called on a generator.

Closes: gh-135110
-->


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

@python-cla-bot
Copy link

python-cla-bot bot commented Jun 22, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@suryansh18saxena
Copy link
Author

I have opened PR #135819 that clarifies the documentation. Kindly review. Thanks!

@ZeroIntensity
Copy link
Member

Hi, thanks for contributing!

There's already an open PR for this issue: #135152. That's already been approved, so I think this probably won't land.
Sorry :(

@picnixz
Copy link
Member

picnixz commented Jun 22, 2025

Closing as a duplicate then. In the future, look at the end of the issue to see if a PR already exists. TiA.

@picnixz picnixz closed this Jun 22, 2025
@suryansh18saxena suryansh18saxena deleted the fix-generator-doc branch June 22, 2025 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

generator.close() never raises GeneratorExit
3 participants