py: Allow to pass in read-only buffers to viper and inline-asm funcs.

Fixes #4936.
This commit is contained in:
Damien George
2019-08-05 16:32:10 +10:00
parent 2d3d4f7483
commit cd35dd9d9a
6 changed files with 18 additions and 2 deletions

View File

@@ -65,7 +65,7 @@ mp_uint_t mp_native_from_obj(mp_obj_t obj, mp_uint_t type) {
case MP_NATIVE_TYPE_UINT: return mp_obj_get_int_truncated(obj);
default: { // cast obj to a pointer
mp_buffer_info_t bufinfo;
if (mp_get_buffer(obj, &bufinfo, MP_BUFFER_RW)) {
if (mp_get_buffer(obj, &bufinfo, MP_BUFFER_READ)) {
return (mp_uint_t)bufinfo.buf;
} else {
// assume obj is an integer that represents an address