Commit b9e7ed4e authored by Damien George's avatar Damien George
Browse files

py: Oops, fix int.from_bytes to correctly convert bytes!

parent 5213eb35
......@@ -277,8 +277,8 @@ STATIC mp_obj_t int_from_bytes(uint n_args, const mp_obj_t *args) {
// convert the bytes to an integer
machine_uint_t value = 0;
for (uint i = 0; i < bufinfo.len; i++) {
value += ((byte*)bufinfo.buf)[i];
for (const byte* buf = bufinfo.buf + bufinfo.len - 1; buf >= (byte*)bufinfo.buf; buf--) {
value = (value << 8) | *buf;
}
return mp_obj_new_int_from_uint(value);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment