[New-bugs-announce] [issue24161] PyIter_Check returns false positive for objects of type instance

behzad nouri report at bugs.python.org
Sun May 10 22:55:34 CEST 2015


New submission from behzad nouri:

- python 2 only, not reproducible on python 3

Attached file makes an extension module which just returns PyIter_Check value on passed object.

Calling the function with an object of type "instance" returns true, even though the object is not iterator:


    >>> import spam
    >>> class Foo:
    ...     pass
    ... 
    >>> foo = Foo()
    >>> type(foo)
    <type 'instance'>
    >>> spam.isiter(foo)  # <<<< ?!
    1
    >>> next(foo)
    TypeError: instance has no next() method

----------
components: Interpreter Core
files: spammodule.c
messages: 242866
nosy: behzad.nouri
priority: normal
severity: normal
status: open
title: PyIter_Check returns false positive for objects of type instance
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file39335/spammodule.c

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24161>
_______________________________________


More information about the New-bugs-announce mailing list