From 5eb2b1305376d5204391d14f0e4ae213aa8fdaae Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sun, 23 Jul 2023 22:19:15 +0900 Subject: [PATCH] Simply invalidate cache --- Modules/_dbmmodule.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c index 6ea4b7f1e9b43a..bd807698927e86 100644 --- a/Modules/_dbmmodule.c +++ b/Modules/_dbmmodule.c @@ -430,6 +430,8 @@ _dbm_dbm_clear_impl(dbmobject *self, PyTypeObject *cls) assert(state != NULL); check_dbmobject_open(self, state->dbm_error); datum key; + // Invalidate cache + self->di_size = -1; while (1) { key = dbm_firstkey(self->di_dbm); if (key.dptr == NULL) { @@ -440,9 +442,6 @@ _dbm_dbm_clear_impl(dbmobject *self, PyTypeObject *cls) PyErr_SetString(state->dbm_error, "cannot delete item from database"); return NULL; } - if (self->di_size > 0) { - self->di_size--; - } } Py_RETURN_NONE; }