[Patches] [ python-Patches-581944 ] StopIteration should be a sink state

noreply@sourceforge.net noreply@sourceforge.net
Tue, 16 Jul 2002 14:43:18 -0700


Patches item #581944, was opened at 2002-07-15 17:43
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=581944&group_id=5470

Category: Core (C code)
Group: Python 2.3
Status: Open
>Resolution: Accepted
Priority: 5
Submitted By: Guido van Rossum (gvanrossum)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: StopIteration should be a sink state

Initial Comment:
Here's a patch that fixes al known (to me :-)
occurrences of iterators in the core that may continue
to return values from next() after having once raised
StopIteration.

Note that the patch also removes various unused next()
method implementations; the type system provides a
next() method as a wrapper when tp_iternext is defined
in a type object.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2002-07-16 17:43

Message:
Logged In: YES 
user_id=31435

Since you're checking this in, I may as well Accept it and 
assign it back to you <wink>.  +1 from me anyway.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-07-15 19:41

Message:
Logged In: YES 
user_id=6380

Everything that has a tp_iternext slot also defines a next()
method, but those next() methods are never used; they are
overridden by wrap_next(). This is not new, this has been
the case since 2.2! So you're right, enum works fine, but
its next() method is pointless, and I'll remove it -- just
like the others you mentioned. (except cStringIO, which
simply calls PyCallIterm_New()).

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-07-15 18:21

Message:
Logged In: YES 
user_id=33168

I thought enum might need patching.
But it worked fine with the patch.  Shucks. :-)

Do xreadlines, cStringIO, or hotshot need patching?
Those three seem to use iterators and could be a problem.

Everything worked fine for me.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-07-15 17:44

Message:
Logged In: YES 
user_id=6380

Oops, here's the file...

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=581944&group_id=5470