]> git.ipfire.org Git - pakfire.git/commitdiff
python: Minor code cleanups in Solution class
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 27 Jan 2025 16:40:23 +0000 (16:40 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 27 Jan 2025 16:40:23 +0000 (16:40 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/solution.c

index 1417b0191f61dea41a5e7a2cc5ce6daefa414fd7..3c09887f5853a3f6451b26e10c209b77b3ab93ef 100644 (file)
@@ -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);
 }