From 1e47c4d6eac85a833152c5194fd50521a723f735 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 14 May 2018 11:20:23 +0200 Subject: [PATCH] bindings: python: change the return value of gpiod_LineBulk_event_wait() gpiod_Line_event_wait() works differently than its LineBulk counterpart. While the latter returns either a list of lines or False, the former returns True if an event occurred on this line or False otherwise. False is not a good counterpart for an actual object, so instead return None if no events occurred on any of the monitored lines. Signed-off-by: Bartosz Golaszewski --- bindings/python/gpiodmodule.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bindings/python/gpiodmodule.c b/bindings/python/gpiodmodule.c index 02af819..0e1c855 100644 --- a/bindings/python/gpiodmodule.c +++ b/bindings/python/gpiodmodule.c @@ -432,8 +432,11 @@ static PyObject *gpiod_Line_event_wait(gpiod_LineObject *self, Py_DECREF(bulk_obj); if (!events) return NULL; - if (events == Py_False) - return Py_False; + + if (events == Py_None) { + Py_DECREF(Py_None); + Py_RETURN_FALSE; + } Py_DECREF(events); Py_RETURN_TRUE; @@ -1008,7 +1011,7 @@ static PyObject *gpiod_LineBulk_event_wait(gpiod_LineBulkObject *self, PyErr_SetFromErrno(PyExc_OSError); return NULL; } else if (rv == 0) { - Py_RETURN_FALSE; + Py_RETURN_NONE; } ret = PyList_New(gpiod_line_bulk_num_lines(&ev_bulk)); -- 2.30.2