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

noreply@sourceforge.net noreply@sourceforge.net
Tue, 16 Jul 2002 18:17:26 -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: Guido van Rossum (gvanrossum)
Date: 2002-07-16 21:17

Message:
Logged In: YES 
user_id=6380

There's some reworking of xreadlines in the pipeline in
another patch (580386); I'll make sure to check this part too.

Hotshot is a little harder, but Fred told me what I can do.

Reopening as reminder.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-07-16 18:25

Message:
Logged In: YES 
user_id=33168

I'm not sure if these are problems or not, but just to be
safe... There are 2 Modules/ that still have iterators that
aren't tested:  xreadlinesmodule.c and _hotshot.c.  

I missed xreadlines the first time, so I'm not sure if it's
been reviewed.
And I thought Guido said hotshot was broken here:
http://mail.python.org/pipermail/python-dev/2002-July/026613.html.


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

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-07-16 18:04

Message:
Logged In: YES 
user_id=6380

Yeah, it's all checked in. :-)

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

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