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 rhettinger
Recipients behzad.nouri, docs@python, rhettinger
Date 2015-05-11.01:33:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> but then, what would be the use case of PyIter_Check
> outside of python core?

You could still use it anywhere.  It will give a correct result in the cases of extension modules, builtin types, and new-style classes.  It will give a false positive in the case of old-style classes.  The latter case doesn't seem to be of much consequence (there is a still a TypeError raised when next() is called), so you just find out a bit later than you otherwise would (I believe that is why this is why we haven't gotten a bug report in the 13+ years this code has existed).

The feature is imperfect, incomplete and not as useful as it could be.
But this ship sailed a long time ago.  It is far too late for redesign (and risking unintended breakage).

FWIW, PyIter_Check() is used several times in the Python core: sqlite, cPickle, and iter().  In those examples, there seem to be no adverse consequences for the false positive because we still get a TypeError downstream when the actual call is made to next().
Date User Action Args
2015-05-11 01:33:30rhettingersetrecipients: + rhettinger, docs@python, behzad.nouri
2015-05-11 01:33:30rhettingersetmessageid: <>
2015-05-11 01:33:30rhettingerlinkissue24161 messages
2015-05-11 01:33:29rhettingercreate