classification
Title: PyIter_Check(obj) fails when obj is of type PySetType
Type: Stage:
Components: Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: damianeads, pitrou
Priority: normal Keywords:

Created on 2009-11-14 09:08 by damianeads, last changed 2009-11-14 13:42 by pitrou. This issue is now closed.

Messages (2)
msg95229 - (view) Author: Damian Eads (damianeads) Date: 2009-11-14 09:08
The instructions for the C interface to the Python set class

  http://docs.python.org/c-api/set.html

say to use PyObject_GetIter and follow the iterator protocol. After
following the instructions for the iterator protocol here,

  http://docs.python.org/c-api/iter.html

I was able to successfully iterate through a set object. However,
PyIter_Check(obj) returns false yet set objects follow the iterator
protocol. Is this the correct behavior?

Thank you.

Kind regards,

Damian Eads
msg95240 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-11-14 13:42
Set objects are iterable, they are not iterators themselves.
In other words, PyIter_Check() should return true when called with the
result of PyObject_GetIter() (but normally you don't need to check anyway).
History
Date User Action Args
2009-11-14 13:42:33pitrousetstatus: open -> closed

nosy: + pitrou
messages: + msg95240

resolution: not a bug
2009-11-14 09:08:46damianeadscreate