diff options
-rw-r--r-- | gi/pygobject.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gi/pygobject.h b/gi/pygobject.h index 37624292..d2425152 100644 --- a/gi/pygobject.h +++ b/gi/pygobject.h @@ -343,11 +343,13 @@ pygobject_init(int req_major, int req_minor, int req_micro) } cobject = PyObject_GetAttrString(gobject, "_PyGObject_API"); - if (cobject && PyCapsule_CheckExact(cobject)) + if (cobject && PyCapsule_CheckExact(cobject)) { _PyGObject_API = (struct _PyGObject_Functions *) PyCapsule_GetPointer(cobject, "gobject._PyGObject_API"); - else { + Py_DECREF (cobject); + } else { PyErr_SetString(PyExc_ImportError, "could not import gobject (could not find _PyGObject_API object)"); + Py_XDECREF (cobject); Py_DECREF(gobject); return NULL; } |