Skip to content

Commit

Permalink
Simply invalidate cache
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 committed Jul 23, 2023
1 parent ee3fd12 commit f7b8698
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Modules/_dbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down

0 comments on commit f7b8698

Please sign in to comment.