8000 bpo-44116: Add GC support to _csv heap types by erlend-aasland · Pull Request #26074 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-44116: Add GC support to _csv heap types #26074

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 4 commits into from
May 12, 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
Only dealloc should free memory
  • Loading branch information
Erlend E. Aasland committed May 12, 2021
commit fe74fc2dd9ca1a59e3f12a0bb5adaf0c36834b85
14 changes: 7 additions & 7 deletions Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,10 @@ Reader_dealloc(ReaderObj *self)
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
tp->tp_clear((PyObject *)self);
if (self->field != NULL) {
PyMem_Free(self->field);
self->field = NULL;
}
PyObject_GC_Del(self);
Py_DECREF(tp);
}
Expand All @@ -917,10 +921,6 @@ Reader_clear(ReaderObj *self)
Py_CLEAR(self->dialect);
Py_CLEAR(self->input_iter);
Py_CLEAR(self->fields);
if (self->field != NULL) {
PyMem_Free(self->field);
self->field = NULL;
}
return 0;
}

Expand Down Expand Up @@ -1346,9 +1346,6 @@ Writer_clear(WriterObj *self)
Py_CLEAR(self->dialect);
Py_CLEAR(self->write);
Py_CLEAR(self->error_obj);
if (self->rec != NULL) {
PyMem_Free(self->rec);
}
return 0;
}

Expand All @@ -1358,6 +1355,9 @@ Writer_dealloc(WriterObj *self)
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
tp->tp_clear((PyObject *)self);
if (self->rec != NULL) {
PyMem_Free(self->rec);
}
PyObject_GC_Del(self);
Py_DECREF(tp);
}
Expand Down
0