From: Michael Tremer Date: Mon, 27 Jan 2025 16:40:23 +0000 (+0000) Subject: python: Minor code cleanups in Solution class X-Git-Tag: 0.9.30~342 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1af291d956b6f5de7956f080959b78e2ad5b1ef7;p=pakfire.git python: Minor code cleanups in Solution class Signed-off-by: Michael Tremer --- diff --git a/src/python/solution.c b/src/python/solution.c index 1417b019..3c09887f 100644 --- a/src/python/solution.c +++ b/src/python/solution.c @@ -47,7 +47,8 @@ static PyObject* Solution_new(PyTypeObject* type, PyObject* args, PyObject* kwds } static void Solution_dealloc(SolutionObject* self) { - pakfire_solution_unref(self->solution); + if (self->solution) + pakfire_solution_unref(self->solution); Py_TYPE(self)->tp_free((PyObject *)self); } @@ -58,6 +59,10 @@ static int Solution_init(SolutionObject* self, PyObject* args, PyObject* kwds) { static PyObject* Solution_string(SolutionObject* self) { const char* string = pakfire_solution_to_string(self->solution); + if (!string) { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } return PyUnicode_FromString(string); }