Raymond Hettinger added the comment:

> 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().

----------
assignee:  -> docs@python
components: +Documentation -Interpreter Core
nosy: +docs@python
priority: normal -> low
stage:  -> needs patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24161>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to