From 4a0a0f7ef136663fad9fee9b9462e4efe03cf4bc Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 8 Jan 2018 17:33:23 +0000 Subject: [PATCH] python: Handle error codes when searching for an AS Signed-off-by: Michael Tremer --- src/python/database.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/python/database.c b/src/python/database.c index 931b54d..7bac3bc 100644 --- a/src/python/database.c +++ b/src/python/database.c @@ -86,19 +86,21 @@ static PyObject* Database_get_as(DatabaseObject* self, PyObject* args) { // Try to retrieve the AS int r = loc_database_get_as(self->db, &as, number); - if (r) - return NULL; - // Create an AS object - if (as) { + // We got an AS + if (r == 0) { PyObject* obj = new_as(&ASType, as); loc_as_unref(as); return obj; - } // Nothing found - Py_RETURN_NONE; + } else if (r == 1) { + Py_RETURN_NONE; + } + + // Unexpected error + return NULL; } static PyObject* Database_lookup(DatabaseObject* self, PyObject* args) { -- 2.39.2