This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: StopIteration should be a sink state
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, nnorwitz, tim.peters
Priority: normal Keywords: patch

Created on 2002-07-15 21:43 by gvanrossum, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
sinkstop.patch gvanrossum, 2002-07-15 21:44 Patch, first version.
Messages (9)
msg40598 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-07-15 21:43
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.
msg40599 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-07-15 21:44
Logged In: YES 
user_id=6380

Oops, here's the file...
msg40600 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-07-15 22:21
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.
msg40601 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-07-15 23:41
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()).
msg40602 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2002-07-16 21:43
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.
msg40603 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-07-16 22:04
Logged In: YES 
user_id=6380

Yeah, it's all checked in. :-)
msg40604 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-07-16 22:25
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.
msg40605 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-07-17 01:17
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.
msg40606 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-07-17 16:51
Logged In: YES 
user_id=6380

Hotshot changes checked in.

The xreadlines stuff will be discussed in patch 580386.

So closing this again.
History
Date User Action Args
2022-04-10 16:05:30adminsetgithub: 36900
2002-07-15 21:43:57gvanrossumcreate