8000 bpo-42972: Fully support GC for pyexpat, unicodedata, and dbm/gdbm heap types by erlend-aasland · Pull Request #26376 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-42972: Fully support GC for pyexpat, unicodedata, and dbm/gdbm heap types #26376

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 3 commits into from
May 27, 2021
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-42972: unicodedata
  • Loading branch information
Erlend E. Aasland committed May 26, 2021
commit 2a2617c831f614685c125a1639866101cef4201f
17 changes: 14 additions & 3 deletions Modules/unicodedata.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,13 @@ new_previous_version(PyTypeObject *ucd_type,
Py_UCS4 (*normalization)(Py_UCS4))
{
PreviousDBVersion *self;
self = PyObject_New(PreviousDBVersion, ucd_type);
self = PyObject_GC_New(PreviousDBVersion, ucd_type);
if (self == NULL)
return NULL;
self->name = name;
self->getrecord = getrecord;
self->normalization = normalization;
PyObject_GC_Track(self);
return (PyObject*)self;
}

Expand Down Expand Up @@ -1435,16 +1436,25 @@ static PyMethodDef unicodedata_functions[] = {
{NULL, NULL} /* sentinel */
};

static int
ucd_traverse(PreviousDBVersion *self, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(self));
return 0;
}

static void
ucd_dealloc(PreviousDBVersion *self)
{
PyTypeObject *tp = Py_TYPE(self);
PyObject_Free(self);
PyObject_GC_UnTrack(self);
PyObject_GC_Del(self);
Py_DECREF(tp);
}

static PyType_Slot ucd_type_slots[] = {
{Py_tp_dealloc, ucd_dealloc},
{Py_tp_traverse, ucd_traverse},
{Py_tp_getattro, PyObject_GenericGetAttr},
{Py_tp_methods, unicodedata_functions},
{Py_tp_members, DB_members},
Expand All @@ -1454,7 +1464,8 @@ static PyType_Slot ucd_type_slots[] = {
static PyType_Spec ucd_type_spec = {
.name = "unicodedata.UCD",
.basicsize = sizeof(PreviousDBVersion),
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION |
Py_TPFLAGS_HAVE_GC),
.slots = ucd_type_slots
};

Expand Down
0