From 1b2c503b340dc0493b23cade52c2cfd5bb1774d0 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 6 Feb 2025 22:30:27 +0000 Subject: [PATCH] python: package: Drop storing a reference to the context 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 --- src/python/package.c | 7 +------ src/python/package.h | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/python/package.c b/src/python/package.c index afa7adaa2..949b7824d 100644 --- a/src/python/package.c +++ b/src/python/package.c @@ -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; } diff --git a/src/python/package.h b/src/python/package.h index dc4cddcd1..98c34e14c 100644 --- a/src/python/package.h +++ b/src/python/package.h @@ -30,7 +30,6 @@ typedef struct { PyObject_HEAD - struct pakfire_ctx* ctx; struct pakfire_package* package; } PackageObject; -- 2.39.5