Skip to content
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

Make dealloc use tp_free or don't allow inheritance #355

Merged
merged 1 commit into from
Mar 27, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 0 additions & 4 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,3 @@ Other
- Make the Py_LOCAL_INLINE macro to work with Python 2.6, 2.7 and 3.1
- Use surrogateescape in Python 3, see PEP-383
- Expose the ODB (Repository.odb)
- According to Python documentation, tp_dealloc must call tp_free (instead of
PyObject_Del or similar) if the type is subclassable. So, go through the
code and switch to tp_free, or make the type not subclassable, on a case by
case basis.
6 changes: 3 additions & 3 deletions src/blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ PyTypeObject BlameHunkType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
BlameHunk__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down Expand Up @@ -233,7 +233,7 @@ PyTypeObject BlameIterType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
BlameIter__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down Expand Up @@ -362,7 +362,7 @@ PyTypeObject BlameType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
Blame__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down
2 changes: 1 addition & 1 deletion src/blob.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ PyTypeObject BlobType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
Blob__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down
2 changes: 1 addition & 1 deletion src/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ PyTypeObject CommitType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
Commit__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down
2 changes: 1 addition & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void
Config_dealloc(Config *self)
{
git_config_free(self->config);
PyObject_Del(self);
Py_TYPE(self)->tp_free(self);
}

PyDoc_STRVAR(Config_get_global_config__doc__,
Expand Down
4 changes: 2 additions & 2 deletions src/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ PyTypeObject PatchType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
Patch__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down Expand Up @@ -269,7 +269,7 @@ PyTypeObject DiffIterType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
DiffIter__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down
4 changes: 2 additions & 2 deletions src/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Index_dealloc(Index* self)
PyObject_GC_UnTrack(self);
Py_XDECREF(self->repo);
git_index_free(self->index);
PyObject_GC_Del(self);
Py_TYPE(self)->tp_free(self);
}

int
Expand Down Expand Up @@ -561,7 +561,7 @@ void
IndexIter_dealloc(IndexIter *self)
{
Py_CLEAR(self->owner);
PyObject_Del(self);
Py_TYPE(self)->tp_free(self);
}

PyObject *
Expand Down
4 changes: 2 additions & 2 deletions src/note.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ PyTypeObject NoteType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
Note__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down Expand Up @@ -200,7 +200,7 @@ PyTypeObject NoteIterType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
NoteIter__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down
2 changes: 1 addition & 1 deletion src/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Object_dealloc(Object* self)
{
Py_CLEAR(self->repo);
git_object_free(self->obj);
PyObject_Del(self);
Py_TYPE(self)->tp_free(self);
}


Expand Down
2 changes: 1 addition & 1 deletion src/reference.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ PyTypeObject RefLogIterType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
RefLogIterType__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down
2 changes: 1 addition & 1 deletion src/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ PyTypeObject RemoteType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
Remote__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down
2 changes: 1 addition & 1 deletion src/repository.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Repository_dealloc(Repository *self)
Py_CLEAR(self->index);
Py_CLEAR(self->config);
git_repository_free(self->repo);
PyObject_GC_Del(self);
Py_TYPE(self)->tp_free(self);
}

int
Expand Down
2 changes: 1 addition & 1 deletion src/tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ PyTypeObject TagType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
Tag__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down
6 changes: 3 additions & 3 deletions src/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ PyTypeObject TreeEntryType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
TreeEntry__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down Expand Up @@ -518,7 +518,7 @@ PyTypeObject TreeType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
Tree__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down Expand Up @@ -589,7 +589,7 @@ PyTypeObject TreeIterType = {
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
Py_TPFLAGS_DEFAULT, /* tp_flags */
TreeIter__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
Expand Down