From 72c45e6f5d12e8cf333ab15a17b41449bebcc5e6 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Mon, 30 May 2016 03:16:16 -0700 Subject: [PATCH] Fix Fatal Python error: UNREF invalid object in debug builds PyObject_Del() should only be called on the self object in a dealloc call, not after failing to make a new object. Replace with Py_DECREF, which eventually calls PyObject_Del() http://bugs.python.org/issue3299#msg78740 https://mail.python.org/pipermail/python-dev/2003-February/033258.html --- _imagingft.c | 2 +- map.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/_imagingft.c b/_imagingft.c index dc1661f3e..218d8b141 100644 --- a/_imagingft.c +++ b/_imagingft.c @@ -153,7 +153,7 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw) if (self->font_bytes) { PyMem_Free(self->font_bytes); } - PyObject_Del(self); + Py_DECREF(self); return geterror(error); } diff --git a/map.c b/map.c index dc9ead0aa..7309a7bd7 100644 --- a/map.c +++ b/map.c @@ -73,7 +73,7 @@ PyImaging_MapperNew(const char* filename, int readonly) NULL); if (mapper->hFile == (HANDLE)-1) { PyErr_SetString(PyExc_IOError, "cannot open file"); - PyObject_Del(mapper); + Py_DECREF(mapper); return NULL; } @@ -84,7 +84,7 @@ PyImaging_MapperNew(const char* filename, int readonly) if (mapper->hMap == (HANDLE)-1) { CloseHandle(mapper->hFile); PyErr_SetString(PyExc_IOError, "cannot map file"); - PyObject_Del(mapper); + Py_DECREF(mapper); return NULL; }