event: Don't use _PyGen_FetchStopIterationValue in Python 3.13+ #1526
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.
Issue description
Python 3.13 has unpublished the _PyGen_FetchStopIterationValue private C API call. It is now part of the internal API: python/cpython#106320
Solution description
This pull request replaces the private _PyGen_FetchStopIterationValue API call with the new PyErr_GetRaisedException API call, added in Python 3.12.
Because the versioning is so complicated (
PyErr_GetRaisedException
being added in Python 3.12,_PyGen_FetchStopIterationValue
not working in Python 3.13, older versions need to be supported still) I have decided to do the following:PyErr_GetRaisedException
on Python 3.13+Right now this code is not covered by the test suite, given that Python 3.13 is still in alpha.
Checklist
I have done my best to ensure that…