From 63b0a2eb21386e1c6b1e5d97421085d543150c2c Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 30 Apr 2008 20:02:37 +0000 Subject: [PATCH] #2727: clarify tp_iternext docs. --- Doc/c-api/typeobj.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index e89ecf70fa..1807c92b5e 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -753,11 +753,12 @@ set. .. cmember:: iternextfunc PyTypeObject.tp_iternext - An optional pointer to a function that returns the next item in an iterator, or - raises :exc:`StopIteration` when the iterator is exhausted. Its presence - normally signals that the instances of this type are iterators (although classic - instances always have this function, even if they don't define a :meth:`next` - method). + An optional pointer to a function that returns the next item in an iterator. + When the iterator is exhausted, it must return *NULL*; a :exc:`StopIteration` + exception may or may not be set. When another error occurs, it must return + *NULL* too. Its presence normally signals that the instances of this type + are iterators (although classic instances always have this function, even if + they don't define a :meth:`next` method). Iterator types should also define the :attr:`tp_iter` function, and that function should return the iterator instance itself (not a new iterator -- 2.40.0