On Tue, Oct 6, 2020 at 7:26 PM Jiri Benc <jbenc@xxxxxxx> wrote: > > On an attempt to call the 'request' method of a Line object, the program > crashes with this exception: > > > SystemError: ../Objects/dictobject.c:2606: bad argument to internal function > > > > The above exception was the direct cause of the following exception: > > > > Traceback (most recent call last): > > File "<stdin>", line 1, in <module> > > SystemError: <class 'gpiod.LineBulk'> returned a result with an error set > > The problem is that keyword args are NULL (rather than an empty dict) if > they are not present. However, PyDict_Size sets an exception if it gets > NULL. > > Fixes: 02a3d0a2ab5e ("bindings: python: fix segfault when calling Line.request()") > Signed-off-by: Jiri Benc <jbenc@xxxxxxx> > --- > bindings/python/gpiodmodule.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/bindings/python/gpiodmodule.c b/bindings/python/gpiodmodule.c > index b3ae2bfebb8a..fee4c32406fa 100644 > --- a/bindings/python/gpiodmodule.c > +++ b/bindings/python/gpiodmodule.c > @@ -472,7 +472,7 @@ static PyObject *gpiod_Line_request(gpiod_LineObject *self, > gpiod_LineBulkObject *bulk_obj; > int rv; > > - if (PyDict_Size(kwds) > 0) { > + if (kwds && PyDict_Size(kwds) > 0) { > def_val = PyDict_GetItemString(kwds, "default_val"); > def_vals = PyDict_GetItemString(kwds, "default_vals"); > } else { > -- > 2.18.1 > Hi Jiri! Thanks for the fixes. Could you send me a chunk of code that triggers this error so I can make a test-case for it? Bartosz