gh-105201: Add PyIter_NextItem() (#122331)

Return -1 and set an exception on error; return 0 if the iterator is
exhausted, and return 1 if the next item was fetched successfully.

Prefer this API to PyIter_Next(), which requires the caller to use
PyErr_Occurred() to differentiate between iterator exhaustion and errors.

Co-authered-by: Irit Katriel <iritkatriel@yahoo.com>
This commit is contained in:
Erlend E. Aasland 2024-08-08 00:47:15 +02:00 committed by GitHub
parent 540fcc62f5
commit e006c7371d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 156 additions and 40 deletions

View file

@ -404,6 +404,10 @@ New Features
(Contributed by Victor Stinner in :gh:`119182`.)
* Add :c:func:`PyIter_NextItem` to replace :c:func:`PyIter_Next`,
which has an ambiguous return value.
(Contributed by Irit Katriel and Erlend Aasland in :gh:`105201`.)
Porting to Python 3.14
----------------------