aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartekgola@gmail.com>2018-05-14 11:20:23 +0200
committerBartosz Golaszewski <bartekgola@gmail.com>2018-05-14 12:01:13 +0200
commit1e47c4d6eac85a833152c5194fd50521a723f735 (patch)
tree1c4d3de2a0af44a580597fec52f24b65a7124041
parent15a623a7d29014e9c03f37be2ba45a2a7e31971f (diff)
downloadlibgpiod-1e47c4d6eac85a833152c5194fd50521a723f735.tar.gz
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 <bartekgola@gmail.com>
-rw-r--r--bindings/python/gpiodmodule.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/bindings/python/gpiodmodule.c b/bindings/python/gpiodmodule.c
index 02af8195..0e1c8556 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));