diff --git a/spidev_module.c b/spidev_module.c index ad3c342..2d89714 100644 --- a/spidev_module.c +++ b/spidev_module.c @@ -184,8 +184,11 @@ SpiDev_writebytes(SpiDevObject *self, PyObject *args) return NULL; seq = PySequence_Fast(obj, "expected a sequence"); + if (!seq) + return NULL; + len = PySequence_Fast_GET_SIZE(seq); - if (!seq || len <= 0) { + if (len <= 0) { PyErr_SetString(PyExc_TypeError, wrmsg_list0); return NULL; }