python: Raise proper error when database does not exist
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Feb 2018 13:39:27 +0000 (13:39 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Feb 2018 13:39:27 +0000 (13:39 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/database.c

index 3c9e024..739d7a4 100644 (file)
@@ -50,8 +50,10 @@ static int Database_init(DatabaseObject* self, PyObject* args, PyObject* kwargs)
 
        // Open the file for reading
        FILE* f = fopen(self->path, "r");
-       if (!f)
+       if (!f) {
+               PyErr_SetFromErrno(PyExc_IOError);
                return -1;
+       }
 
        // Load the database
        int r = loc_database_new(loc_ctx, &self->db, f);