[python] Upgrade to micropython 1.11

This commit is contained in:
Léa Saviot
2019-08-21 09:59:33 +02:00
parent 127a166762
commit 0975ba0f10
115 changed files with 4605 additions and 2450 deletions

View File

@@ -88,7 +88,7 @@ typedef uint32_t mp_float_uint_t;
if (adj_exp <= MP_FLOAT_FRAC_BITS) {
// number may have a fraction; xor the integer part with the fractional part
val = (frc >> (MP_FLOAT_FRAC_BITS - adj_exp))
^ (frc & ((1 << (MP_FLOAT_FRAC_BITS - adj_exp)) - 1));
^ (frc & (((mp_float_uint_t)1 << (MP_FLOAT_FRAC_BITS - adj_exp)) - 1));
} else if ((unsigned int)adj_exp < BITS_PER_BYTE * sizeof(mp_int_t) - 1) {
// the number is a (big) whole integer and will fit in val's signed-width
val = (mp_int_t)frc << (adj_exp - MP_FLOAT_FRAC_BITS);
@@ -99,7 +99,7 @@ typedef uint32_t mp_float_uint_t;
}
if (u.p.sgn) {
val = -val;
val = -(mp_uint_t)val;
}
return val;
@@ -161,8 +161,7 @@ STATIC mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
case MP_UNARY_OP_POSITIVE: return o_in;
case MP_UNARY_OP_NEGATIVE: return mp_obj_new_float(-val);
case MP_UNARY_OP_ABS: {
// TODO check for NaN etc
if (val < 0) {
if (signbit(val)) {
return mp_obj_new_float(-val);
} else {
return o_in;
@@ -175,7 +174,7 @@ STATIC mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
STATIC mp_obj_t float_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_float_t lhs_val = mp_obj_float_get(lhs_in);
#if MICROPY_PY_BUILTINS_COMPLEX
if (MP_OBJ_IS_TYPE(rhs_in, &mp_type_complex)) {
if (mp_obj_is_type(rhs_in, &mp_type_complex)) {
return mp_obj_complex_binary_op(op, lhs_val, 0, rhs_in);
} else
#endif
@@ -262,7 +261,7 @@ mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t
case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE:
if (rhs_val == 0) {
zero_division_error:
mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero");
mp_raise_msg(&mp_type_ZeroDivisionError, "divide by zero");
}
// Python specs require that x == (x//y)*y + (x%y) so we must
// call divmod to compute the correct floor division, which