Amaury Forgeot d'Arc <amaur...@gmail.com> added the comment: 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... ---------- keywords: +needs review status: pending -> open Added file: http://bugs.python.org/file12711/next-nevernull-26.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue3720> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com