]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
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 3c9e02420dca8f2d25f3bdad593f44124686ae72..739d7a440baec5ec783f00dbc859d7b2b2da3c22 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);