diff --git a/src/diff.c b/src/diff.c index b8289d5..e6d53b0 100644 --- a/src/diff.c +++ b/src/diff.c @@ -58,7 +58,7 @@ diff_get_patch_byindex(git_diff_list* list, size_t idx) if (err < 0) return Error_set(err); - py_patch = (Patch*) PyType_GenericNew(&PatchType, NULL, NULL); + py_patch = PyObject_New(Patch, &PatchType); if (py_patch != NULL) { py_patch->old_file_path = delta->old_file.path; py_patch->new_file_path = delta->new_file.path; @@ -77,7 +77,7 @@ diff_get_patch_byindex(git_diff_list* list, size_t idx) if (err < 0) goto cleanup; - py_hunk = (Hunk*)PyType_GenericNew(&HunkType, NULL, NULL); + py_hunk = PyObject_New(Hunk, &HunkType); if (py_hunk != NULL) { py_hunk->old_start = range->old_start; py_hunk->old_lines = range->old_lines; diff --git a/src/note.c b/src/note.c index 110ca8b..2dffbae 100644 --- a/src/note.c +++ b/src/note.c @@ -172,6 +172,7 @@ NoteIter_iternext(NoteIter *self) void NoteIter_dealloc(NoteIter *self) { + Py_CLEAR(self->repo); git_note_iterator_free(self->iter); PyObject_Del(self); } @@ -216,7 +217,7 @@ wrap_note(Repository* repo, git_oid* annotated_id, const char* ref) Note* py_note = NULL; int err = GIT_ERROR; - py_note = (Note*) PyType_GenericNew(&NoteType, NULL, NULL); + py_note = PyObject_New(Note, &NoteType); if (py_note == NULL) { PyErr_NoMemory(); return NULL; diff --git a/src/repository.c b/src/repository.c index e487fc9..5c83cc7 100644 --- a/src/repository.c +++ b/src/repository.c @@ -1053,7 +1053,7 @@ Repository_create_remote(Repository *self, PyObject *args) if (err < 0) return Error_set(err); - py_remote = (Remote*) PyType_GenericNew(&RemoteType, NULL, NULL); + py_remote = PyObject_New(Remote, &RemoteType); py_remote->repo = self; py_remote->remote = remote;