From: Michael Tremer Date: Tue, 4 Feb 2025 18:13:22 +0000 (+0000) Subject: python: Improve readability of the code X-Git-Tag: 0.9.30~136 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d2f72cde8522bddef8a629235675e220464aa00;p=pakfire.git python: Improve readability of the code Signed-off-by: Michael Tremer --- 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); }