There was an error while loading. Please reload this page.
1 parent bb057ea commit 9b32b89Copy full SHA for 9b32b89
1 file changed
Modules/_collectionsmodule.c
@@ -2575,7 +2575,11 @@ _collections__count_elements_impl(PyObject *module, PyObject *mapping,
2575
oldval = PyObject_CallFunctionObjArgs(bound_get, key, zero, NULL);
2576
if (oldval == NULL)
2577
break;
2578
- newval = PyNumber_Add(oldval, one);
+ if (oldval == zero) {
2579
+ newval = Py_NewRef(one);
2580
+ } else {
2581
+ newval = PyNumber_Add(oldval, one);
2582
+ }
2583
Py_DECREF(oldval);
2584
if (newval == NULL)
2585
0 commit comments