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.
https://github.com/v923z/micropython-ulab/blob/743d86487c83e42024ed508ed50499ad0a527d5d/code/ndarray.c#L1989-L1994
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.
ulab 1.7.2 still defines the routine
ndarray_get_buffer(). This code callsmp_get_buffer(self->array, ...). However, my understanding from readingcreate_zeros_ones_full()is thatself->arrayis 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.https://github.com/v923z/micropython-ulab/blob/743d86487c83e42024ed508ed50499ad0a527d5d/code/ndarray.c#L1989-L1994
I had some code similar to this in CircuitPython:
_bleio.Characteristic.valueexpects the value coming in to obey buffer protocol, and callsmp_get_buffer()on thendarray. That in turn callsndarray_get_buffer(), which tries to callmp_get_buffer()on thearrayitself, and things go wrong.ndarray_get_buffer()seems to have disappeared in 2.xulab, so I'm not sure how to fix 1.7.2. Is there something new to backport to 1.7.x? Thanks.