]> git.ipfire.org Git - pakfire.git/commitdiff
python: Improve readability of the code
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 4 Feb 2025 18:13:22 +0000 (18:13 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 4 Feb 2025 18:13:22 +0000 (18:13 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/pakfire.c

index 962c399bbe4981f9396acab34972188f6fef3858..fe4c7cf119901b5162445b8dadf0891d0f74439d 100644 (file)
@@ -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);
 }