Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-1635741: Port _dbm module to multiphase initialization #20848

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 9 commits into from
Jun 15, 2020
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
bpo-1635741: Apply Victor's review
  • Loading branch information
corona10 committed Jun 15, 2020
commit 7ec3d5c79e117bd7760be3130570cfd8484d1f16
12 changes: 9 additions & 3 deletions 12 Modules/_dbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ newdbmobject(_dbm_state *state, const char *file, int flags, int mode)
static void
dbm_dealloc(dbmobject *dp)
{
if ( dp->di_dbm )
if (dp->di_dbm) {
dbm_close(dp->di_dbm);
}
PyTypeObject *tp = Py_TYPE(dp);
freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
free_func(dp);
tp->tp_free(dp);
Py_DECREF(tp);
vstinner marked this conversation as resolved.
Show resolved Hide resolved
}

Expand All @@ -97,6 +97,7 @@ dbm_length(dbmobject *dp)
{
PyTypeObject *tp = Py_TYPE(dp);
_dbm_state *state = PyType_GetModuleState(tp);
corona10 marked this conversation as resolved.
Show resolved Hide resolved
corona10 marked this conversation as resolved.
Show resolved Hide resolved
assert(state != NULL);
if (state == NULL) {
return -1;
}
Expand Down Expand Up @@ -419,9 +420,14 @@ static PyType_Slot dbmtype_spec_slots[] = {
{0, 0}
};


static PyType_Spec dbmtype_spec = {
.name = "_dbm.dbm",
.basicsize = sizeof(dbmobject),
/*
Calling PyType_GetModuleState() is safe
because Py_TPFLAGS_BASETYPE flag is not used.
*/
corona10 marked this conversation as resolved.
Show resolved Hide resolved
.flags = Py_TPFLAGS_DEFAULT,
corona10 marked this conversation as resolved.
Show resolved Hide resolved
.slots = dbmtype_spec_slots,
};
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.