-
Notifications
You must be signed in to change notification settings - Fork 128
Description
ulab 1.7.2 still defines the routine ndarray_get_buffer(). This code calls mp_get_buffer(self->array, ...). However, my understanding from reading create_zeros_ones_full() is that self->array is the raw array of values. It is not a Python object. mp_get_buffer() expects its first arg to be a Python object, so bad things happen.
mp_int_t ndarray_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
ndarray_obj_t *self = MP_OBJ_TO_PTR(self_in);
// buffer_p.get_buffer() returns zero for success, while mp_get_buffer returns true for success
return !mp_get_buffer(self->array, bufinfo, flags);
}I had some code similar to this in CircuitPython:
a = ulab.zeros(10, dtype=ulab.uint16)
some_bleio_characteristic.value = a_bleio.Characteristic.value expects the value coming in to obey buffer protocol, and calls mp_get_buffer() on the ndarray. That in turn calls ndarray_get_buffer(), which tries to call mp_get_buffer() on the array itself, and things go wrong.
ndarray_get_buffer() seems to have disappeared in 2.x ulab, so I'm not sure how to fix 1.7.2. Is there something new to backport to 1.7.x? Thanks.