[issue24659] dict() built-in fails on iterators with a "keys" attribute

2019-08-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: This doesn't appear to have been an ongoing source of confusion. Over time, the existence of the glossary entries and the collections ABCs seems to have provided the needed clarity. -- resolution: -> out of date stage: needs patch -> resolved st

[issue24659] dict() built-in fails on iterators with a "keys" attribute

2015-07-23 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- priority: normal -> low stage: -> needs patch ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue24659] dict() built-in fails on iterators with a "keys" attribute

2015-07-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: > I'm aware of duck typing but I don't think this > is the right place for it. The code for dicts is very old, stable, and unlikely to change. Also, the logic of checking for .keys() is immortalized in the collections.abc.MutableMapping update() method.

[issue24659] dict() built-in fails on iterators with a "keys" attribute

2015-07-18 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: docs@python -> rhettinger nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list ma

[issue24659] dict() built-in fails on iterators with a "keys" attribute

2015-07-18 Thread Christian Barcenas
Christian Barcenas added the comment: I'm aware of duck typing but I don't think this is the right place for it. (Although ABCs are ostensibly a kind of duck typing, as they do not require implementing classes to inherit from the ABC.) As Martin noticed, the glossary directly defines a "mappin

[issue24659] dict() built-in fails on iterators with a "keys" attribute

2015-07-18 Thread Martin Panter
Martin Panter added the comment: It is at least an omission from the documentation. The glossary refers to the Mapping ABC. From Christian’s point of view, the quack of an iterator with just a “keys” attribute sounds more like an iterato

[issue24659] dict() built-in fails on iterators with a "keys" attribute

2015-07-18 Thread R. David Murray
R. David Murray added the comment: Well, this is an example of duck typing, something we commonly do in Python. I'm not convinced this is a bug. -- nosy: +r.david.murray ___ Python tracker ___

[issue24659] dict() built-in fails on iterators with a "keys" attribute

2015-07-18 Thread Christian Barcenas
Christian Barcenas added the comment: Should have clarified that the specific issue that is outlined in #5945 is that PyMapping_Check returns 1 on sequences (e.g. lists), which would mean something like x = [('one', 1), ('two', 2)]; dict(x) would fail in 3.x because x would be incorrectly eval

[issue24659] dict() built-in fails on iterators with a "keys" attribute

2015-07-18 Thread Christian Barcenas
New submission from Christian Barcenas: I noticed an inconsistency today between the dict() documentation vs. implementation. The documentation for the dict() built-in [1] states that the function accepts an optional positional argument that is either a mapping object [2] or an iterable objec