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) { ...@@ -199,18 +199,21 @@ static PyObject* Database_lookup(DatabaseObject* self, PyObject* args) {
loc_network_unref(network); loc_network_unref(network);
return obj; return obj;
}
// Nothing found // Nothing found
} else if (r == 1) { if (!errno)
Py_RETURN_NONE; Py_RETURN_NONE;
// Invalid input // Handle any errors
} else if (r == -EINVAL) { switch (errno) {
PyErr_Format(PyExc_ValueError, "Invalid IP address: %s", address); case EINVAL:
return NULL; PyErr_Format(PyExc_ValueError, "Invalid IP address: %s", address);
default:
PyErr_SetFromErrno(PyExc_OSError);
} }
// Unexpected error
return NULL; 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