8000 gh-107122: Add clear method to dbm.ndbm module by corona10 · Pull Request #107126 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-107122: Add clear method to dbm.ndbm module #107126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Be more safer
  • Loading branch information
corona10 committed Jul 23, 2023
commit 7a7e8266c53e9b55185d3e1424dcb9bb379dd081
3 changes: 2 additions & 1 deletion Modules/_dbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ _dbm_dbm_clear_impl(dbmobject *self, PyTypeObject *cls)
_dbm_state *state = PyType_GetModuleState(cls);
assert(state != NULL);
check_dbmobject_open(self, state->dbm_error);
for (datum key = dbm_firstkey(self->di_dbm); key.dptr; key = dbm_nextkey(self->di_dbm)) {
datum key;
while (key = dbm_firstkey(self->di_dbm), key.dptr) {
if (dbm_delete(self->di_dbm, key) < 0) {
dbm_clearerr(self->di_dbm);
PyErr_SetString(state->dbm_error, "cannot delete item from database");
Expand Down
0