Message303014
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:29 | Oren Milman | set | recipients:
+ Oren Milman |
2017-09-26 06:32:28 | Oren Milman | set | messageid: <1506407548.97.0.597498923385.issue31586@psf.upfronthosting.co.za> |
2017-09-26 06:32:28 | Oren Milman | link | issue31586 messages |
2017-09-26 06:32:28 | Oren Milman | create | |
|