Commit a27e1f3d authored by Michael Tremer's avatar Michael Tremer

python: Fix errors for Database.lookup()

Signed-off-by: default avatarMichael Tremer <michael.tremer@ipfire.org>
parent 808d6ac8
......@@ -199,18 +199,21 @@ static PyObject* Database_lookup(DatabaseObject* self, PyObject* args) {
loc_network_unref(network);
return obj;
}
// Nothing found
} else if (r == 1) {
if (!errno)
Py_RETURN_NONE;
// Invalid input
} else if (r == -EINVAL) {
PyErr_Format(PyExc_ValueError, "Invalid IP address: %s", address);
return NULL;
// Handle any errors
switch (errno) {
case EINVAL:
PyErr_Format(PyExc_ValueError, "Invalid IP address: %s", address);
default:
PyErr_SetFromErrno(PyExc_OSError);
}
// Unexpected error
return NULL;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment