#############################################################################*/
#include <Python.h>
+#include <errno.h>
#include <stdbool.h>
#include <solv/repo.h>
#include <solv/repo_solv.h>
#include <solv/repo_write.h>
+#include "config.h"
#include "pool.h"
#include "repo.h"
#include "solvable.h"
PyObject *Repo_write(RepoObject *self, PyObject *args) {
const char *filename;
+ char exception[STRING_SIZE];
if (!PyArg_ParseTuple(args, "s", &filename)) {
/* XXX raise exception */
_Pool_prepare(self->_repo->pool);
// XXX catch if file cannot be opened
- FILE *fp = fopen(filename, "wb");
+ FILE *fp = NULL;
+ if ((fp = fopen(filename, "wb")) == NULL) {
+ snprintf(exception, STRING_SIZE - 1, "Could not open file for writing: %s (%s).",
+ filename, strerror(errno));
+ PyErr_SetString(PyExc_RuntimeError, exception);
+ return NULL;
+ }
repo_write(self->_repo, fp, NULL, NULL, 0);