New submission from Oren Milman: 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? ---------- components: Extension Modules messages: 303014 nosy: Oren Milman priority: normal severity: normal status: open type: behavior versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31586> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com