| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
The documentation incorrectly stated that generator.close() 'raises' a GeneratorExit exception. This was misleading because the method doesn't raise the exception to the caller - it sends the exception internally to the generator and returns None. Changed 'raises' to 'sends' in both Doc/reference/expressions.rst and Doc/howto/functional.rst for consistency and accuracy. Fixes #135110
Sorry, something went wrong.
There was a problem hiding this comment.
I'm a little worried about the use of the word "send" here, especially considering generator.send() is a thing. I think "raises" is fine, we should just make it clearer that the actual yield expressions are what raise. Maybe we could say that close() is equivalent to throw(GeneratorExit)?
Sorry, something went wrong.
Replace 'sends' with 'raises' and clarify that close() is equivalent to throw(GeneratorExit). This makes the documentation clearer and avoids confusion with generator.send().
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
|
It looks like the CLA got screwed up. |
Sorry, something went wrong.
|
Just signed it again, should be all good now. |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks!
Sorry, something went wrong.
|
Thanks @cdenihan for the PR, and @ZeroIntensity for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
Sorry, something went wrong.
…thonGH-135152) The documentation incorrectly stated that generator.close() 'raises' a GeneratorExit exception. This was misleading because the method doesn't raise the exception to the caller - it sends the exception internally to the generator and returns None. (cherry picked from commit 0d76dcc) Co-authored-by: Connor Denihan <188690869+cdenihan@users.noreply.github.com>
…thonGH-135152) The documentation incorrectly stated that generator.close() 'raises' a GeneratorExit exception. This was misleading because the method doesn't raise the exception to the caller - it sends the exception internally to the generator and returns None. (cherry picked from commit 0d76dcc) Co-authored-by: Connor Denihan <188690869+cdenihan@users.noreply.github.com>
|
GH-135985 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
|
GH-135986 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
…H-135152) (GH-135986) gh-135110: Fix misleading `generator.close()` documentation (GH-135152) The documentation incorrectly stated that generator.close() 'raises' a GeneratorExit exception. This was misleading because the method doesn't raise the exception to the caller - it sends the exception internally to the generator and returns None. (cherry picked from commit 0d76dcc) Co-authored-by: Connor Denihan <188690869+cdenihan@users.noreply.github.com>
…H-135152) (GH-135985) gh-135110: Fix misleading `generator.close()` documentation (GH-135152) The documentation incorrectly stated that generator.close() 'raises' a GeneratorExit exception. This was misleading because the method doesn't raise the exception to the caller - it sends the exception internally to the generator and returns None. (cherry picked from commit 0d76dcc) Co-authored-by: Connor Denihan <188690869+cdenihan@users.noreply.github.com>
…thonGH-135152) The documentation incorrectly stated that generator.close() 'raises' a GeneratorExit exception. This was misleading because the method doesn't raise the exception to the caller - it sends the exception internally to the generator and returns None.
…thonGH-135152) The documentation incorrectly stated that generator.close() 'raises' a GeneratorExit exception. This was misleading because the method doesn't raise the exception to the caller - it sends the exception internally to the generator and returns None.
…thonGH-135152) The documentation incorrectly stated that generator.close() 'raises' a GeneratorExit exception. This was misleading because the method doesn't raise the exception to the caller - it sends the exception internally to the generator and returns None.
…thonGH-135152) The documentation incorrectly stated that generator.close() 'raises' a GeneratorExit exception. This was misleading because the method doesn't raise the exception to the caller - it sends the exception internally to the generator and returns None.
| Back | FazBrowse Home | New Git URL |
This PR fixes the misleading documentation for generator.close() that incorrectly stated the method 'raises a GeneratorExit' to the caller.
Problem
The current documentation in both Doc/reference/expressions.rst and Doc/howto/functional.rst states that generator.close() 'raises a GeneratorExit' which is misleading because:
Solution
Changed 'raises' to 'sends' in both documentation files for accuracy and consistency:
Doc/reference/expressions.rst (line 628-629):
Doc/howto/functional.rst (line 605):
Testing
The behavior described in the fixed documentation can be verified by the examples in the original issue report, which show that generator.close() always returns None.
Fixes #135110
📚 Documentation preview 📚: https://cpython-previews--135152.org.readthedocs.build/