&CtxType, &ctx, &path, &arch, &config, &stub))
return -1;
+ // Keep the reference to the context
+ self->ctx = ctx;
+ Py_INCREF(self->ctx);
+
// Setup flags
if (stub)
flags |= PAKFIRE_FLAGS_STUB;
Py_BEGIN_ALLOW_THREADS
- // Store a reference to the context
- self->ctx = pakfire_ctx_ref(ctx->ctx);
-
// Create a new Pakfire instance
- r = pakfire_create(&self->pakfire, self->ctx, c, path, arch, flags);
+ r = pakfire_create(&self->pakfire, self->ctx->ctx, c, path, arch, flags);
if (r < 0) {
Py_BLOCK_THREADS
errno = -r;
if (self->pakfire)
pakfire_unref(self->pakfire);
- if (self->ctx)
- pakfire_ctx_unref(self->ctx);
Py_END_ALLOW_THREADS
+ Py_XDECREF(self->ctx);
+
Py_TYPE(self)->tp_free((PyObject *)self);
}
return NULL;
// Generate a new key
- int r = pakfire_key_generate(&key, self->ctx, algo, comment);
+ int r = pakfire_key_generate(&key, self->ctx->ctx, algo, comment);
if (r) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
return NULL;
// Import the key
- r = pakfire_key_import(&key, self->ctx, f);
+ r = pakfire_key_import(&key, self->ctx->ctx, f);
if (r) {
PyErr_SetFromErrno(PyExc_OSError);
goto ERROR;
return NULL;
// Create a new list
- r = pakfire_packagelist_create(&list, self->ctx);
+ r = pakfire_packagelist_create(&list, self->ctx->ctx);
if (r < 0) {
errno = -r;
PyErr_SetFromErrno(PyExc_OSError);
Py_BEGIN_ALLOW_THREADS
// Create a new list
- r = pakfire_packagelist_create(&list, self->ctx);
+ r = pakfire_packagelist_create(&list, self->ctx->ctx);
if (r < 0) {
Py_BLOCK_THREADS
errno = -r;
if (name_only)
flags |= PAKFIRE_SEARCH_NAME_ONLY;
- r = pakfire_packagelist_create(&list, self->ctx);
+ r = pakfire_packagelist_create(&list, self->ctx->ctx);
if (r < 0) {
errno = -r;
PyErr_SetFromErrno(PyExc_OSError);
// Parse the environment
if (environ) {
// Create a new environment
- r = pakfire_env_create(&env, self->ctx);
+ r = pakfire_env_create(&env, self->ctx->ctx);
if (r < 0) {
errno = -r;
PyErr_SetFromErrno(PyExc_OSError);