]> git.ipfire.org Git - pakfire.git/commitdiff
python: package: Drop storing a reference to the context
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Feb 2025 22:30:27 +0000 (22:30 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Feb 2025 22:30:27 +0000 (22:30 +0000)
This was an ugly hack to create a new package list which we don't need
any more. This caused the application to occasionally crash because ctx
wasn't set at all times.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/package.c
src/python/package.h

index afa7adaa21bd866769411592278d6a955017a12b..949b7824d6366e271c262bb9017fdccd947dd29c 100644 (file)
@@ -47,7 +47,6 @@ PyObject* new_package(PyTypeObject* type, struct pakfire_package* pkg) {
 static PyObject* Package_new(PyTypeObject* type, PyObject* args, PyObject* kwds) {
        PackageObject* self = (PackageObject *)type->tp_alloc(type, 0);
        if (self) {
-               self->ctx = NULL;
                self->package = NULL;
        }
 
@@ -57,8 +56,6 @@ static PyObject* Package_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
 static void Package_dealloc(PackageObject* self) {
        if (self->package)
                pakfire_package_unref(self->package);
-       if (self->ctx)
-               pakfire_ctx_unref(self->ctx);
 
        Py_TYPE(self)->tp_free((PyObject *)self);
 }
@@ -75,12 +72,10 @@ static int Package_init(PackageObject* self, PyObject* args, PyObject* kwds) {
                        &PakfireType, &pakfire, &RepoType, &repo, &name, &evr, &arch))
                return -1;
 
-       // Store a reference to the context
-       self->ctx = pakfire_ctx_ref(pakfire->ctx);
-
        // Create the package object
        r = pakfire_package_create(&self->package, pakfire->pakfire, repo->repo, name, evr, arch);
        if (r < 0) {
+               errno = -r;
                PyErr_SetFromErrno(PyExc_OSError);
                return -1;
        }
index dc4cddcd1e16d7d0addc8c4482be40eecf3d6175..98c34e14c8061329e412a7425a3b95a0ad60031b 100644 (file)
@@ -30,7 +30,6 @@
 
 typedef struct {
        PyObject_HEAD
-       struct pakfire_ctx* ctx;
        struct pakfire_package* package;
 } PackageObject;