From 8d2f72cde8522bddef8a629235675e220464aa00 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 4 Feb 2025 18:13:22 +0000 Subject: [PATCH] python: Improve readability of the code Signed-off-by: Michael Tremer --- src/python/pakfire.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/python/pakfire.c b/src/python/pakfire.c index 962c399b..fe4c7cf1 100644 --- a/src/python/pakfire.c +++ b/src/python/pakfire.c @@ -102,16 +102,16 @@ static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) { // Create a new Pakfire instance r = pakfire_create(&self->pakfire, self->ctx, c, path, arch, flags); - - Py_END_ALLOW_THREADS - if (r < 0) { + Py_BLOCK_THREADS errno = -r; PyErr_SetFromErrno(PyExc_OSError); goto ERROR; } + Py_END_ALLOW_THREADS + ERROR: if (c) pakfire_config_unref(c); @@ -120,16 +120,15 @@ ERROR: } static void Pakfire_dealloc(PakfireObject* self) { - if (self->pakfire) { - Py_BEGIN_ALLOW_THREADS + Py_BEGIN_ALLOW_THREADS + if (self->pakfire) pakfire_unref(self->pakfire); - - Py_END_ALLOW_THREADS - } if (self->ctx) pakfire_ctx_unref(self->ctx); + Py_END_ALLOW_THREADS + Py_TYPE(self)->tp_free((PyObject *)self); } -- 2.39.5