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 serhiy.storchaka
Recipients aganders3, aviramha, bar.harel, benjamin.peterson, brandtbucher, bukzor, georg.brandl, levkivskyi, methane, miss-islington, petr.viktorin, pitrou, rhettinger, serhiy.storchaka
Date 2022-01-23.17:30:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1642959055.42.0.6225866581.issue46376@roundup.psfhosted.org>
In-reply-to
Content
It is difficult to distinguish Mapping from Sequence because they have the same set of dunder methods. The difference is only in semantic -- __iter__ yields items for Sequence and keys for Mapping, __getitem__ gets an item by index (or a sequence by slice) for Sequence and value by key for Mapping. But semantic cannot be tested here.

In these cases when both Sequence and Mapping are accepted but handled differently (like in the dict constructor) we test for existence of the "keys" method. It is not good, because it is not a dunder method, and therefore should be looked up at instance, not only at a type.
History
Date User Action Args
2022-01-23 17:30:55serhiy.storchakasetrecipients: + serhiy.storchaka, georg.brandl, rhettinger, pitrou, benjamin.peterson, petr.viktorin, methane, bukzor, aganders3, levkivskyi, bar.harel, miss-islington, brandtbucher, aviramha
2022-01-23 17:30:55serhiy.storchakasetmessageid: <1642959055.42.0.6225866581.issue46376@roundup.psfhosted.org>
2022-01-23 17:30:55serhiy.storchakalinkissue46376 messages
2022-01-23 17:30:55serhiy.storchakacreate