]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - src/python/database.c
python: Raise proper error when database does not exist
[people/ms/libloc.git] / 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);