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 Oren Milman
Recipients Oren Milman
Date 2017-09-26.06:32:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The following code causes a SystemError:
class BadMapping:
    get = dict.get
    __setitem__ = dict.__setitem__

import _collections
_collections._count_elements(BadMapping(), [42])

This is because _count_elements() (in Modules/_collectionsmodule.c) assumes
that the mapping argument is a dictionary in case it has the same get() and
__setitem__() methods as dict. And so, _count_elements() passes the mapping
argument to _PyDict_GetItem_KnownHash(), which raises the SystemError.

ISTM it is a very unlikely corner case, so that adding a test (as well as
a NEWS.d item) for it is unnecessary.
What do you think?
Date User Action Args
2017-09-26 06:32:29Oren Milmansetrecipients: + Oren Milman
2017-09-26 06:32:28Oren Milmansetmessageid: <>
2017-09-26 06:32:28Oren Milmanlinkissue31586 messages
2017-09-26 06:32:28Oren Milmancreate