[docs] [issue24161] PyIter_Check returns false positive for objects of type instance
Raymond Hettinger
report at bugs.python.org
Mon May 11 03:33:30 CEST 2015
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 at python
components: +Documentation -Interpreter Core
nosy: +docs at python
priority: normal -> low
stage: -> needs patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24161>
_______________________________________
More information about the docs
mailing list