summaryrefslogtreecommitdiffstats
path: root/Modules/_collectionsmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r--Modules/_collectionsmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index e7a24f3..af20d6e 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -2276,7 +2276,9 @@ _count_elements(PyObject *self, PyObject *args)
dict_setitem = _PyType_LookupId(&PyDict_Type, &PyId___setitem__);
if (mapping_get != NULL && mapping_get == dict_get &&
- mapping_setitem != NULL && mapping_setitem == dict_setitem) {
+ mapping_setitem != NULL && mapping_setitem == dict_setitem &&
+ PyDict_Check(mapping))
+ {
while (1) {
/* Fast path advantages:
1. Eliminate double hashing