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.

Author amaury.forgeotdarc
Recipients ajaksu2, amaury.forgeotdarc, arigo, benjamin.peterson, donmez, gideon, gregory.p.smith, jcea, rhettinger, terry.reedy, vstinner
Date 2009-01-13.00:47:46
SpamBayes Score 0.1726217
Marked as misclassified No
Message-id <1231807672.89.0.242331234379.issue3720@psf.upfronthosting.co.za>
In-reply-to
Content
Yes, a hack: What about setting tp_iternext to PyObject_GetIter? they happen 
to have the same signature.
Yes, calling next() will call iter() instead; but an iterator is often its 
own iterator, and more importantly, PyIter_Check() is also called.

And the error message is surprisingly almost correct:
  "TypeError: iter() returned non-iterator of type 'BadIterator'"
It's not completely correct since the error occurred while calling the 
__next__() method of the iterator.

See attached patch for 2.6.

I can see one cause of incompatibility: if someone designed an extension 
type in C where tp_iternext is already PyObject_GetIter. It's is insane but 
valid, and the patch would break it. It's not worth the trouble I suppose...
History
Date User Action Args
2009-01-13 00:47:53amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, arigo, rhettinger, terry.reedy, gregory.p.smith, jcea, vstinner, ajaksu2, donmez, benjamin.peterson, gideon
2009-01-13 00:47:52amaury.forgeotdarcsetmessageid: <1231807672.89.0.242331234379.issue3720@psf.upfronthosting.co.za>
2009-01-13 00:47:51amaury.forgeotdarclinkissue3720 messages
2009-01-13 00:47:50amaury.forgeotdarccreate