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 Sam De Meyer
Recipients Sam De Meyer, docs@python
Date 2017-05-09.20:19:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
According to the docs ( the `PyObject_GetIter` method should be equivalent to the python call `iter(<some_dict>)`, but, when given a dict, the `PyObject_GetIter` returns an iterator over key-value pairs whereas the `iter()` method returns an iterator over keys only.

I tripped over this when giving the `<some_dict>.update()` a dict-like object that does not inherit from the builtin dict and implements its own `__iter__()`.

The `update()` method eventually reaches the following piece of code:

>    it = PyObject_GetIter(seq2);
> ...
>        item = PyIter_Next(it);
> ...
>        fast = PySequence_Fast(item, "");
> ...
>        key = PySequence_Fast_GET_ITEM(fast, 0);
>        value = PySequence_Fast_GET_ITEM(fast, 1);

displaying the difference in behaviour between `PyObject_GetIter` and `iter(o)`.
Date User Action Args
2017-05-09 20:19:39Sam De Meyersetrecipients: + Sam De Meyer, docs@python
2017-05-09 20:19:39Sam De Meyersetmessageid: <>
2017-05-09 20:19:39Sam De Meyerlinkissue30322 messages
2017-05-09 20:19:39Sam De Meyercreate