Skip to content

Commit baf6f14

Browse files
committed
Enhance str.format support
This adds support for almost everything (the comma isn't currently supported). The "unspecified" type with floats also doesn't behave exactly like python. Tested under unix with float and double Spot tested on stmhal
1 parent e44d26a commit baf6f14

8 files changed

Lines changed: 776 additions & 141 deletions

File tree

py/formatfloat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
***********************************************************************/
1515

1616
#include <stdlib.h>
17+
#include <stdint.h>
1718

1819
#include "mpconfig.h"
1920

py/obj.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ machine_int_t mp_obj_get_int(mp_obj_t arg) {
198198
return MP_OBJ_SMALL_INT_VALUE(arg);
199199
} else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) {
200200
return mp_obj_int_get_checked(arg);
201+
#if MICROPY_ENABLE_FLOAT
202+
} else if (MP_OBJ_IS_TYPE(arg, &mp_type_float)) {
203+
return mp_obj_float_get(arg);
204+
#endif
201205
} else {
202206
nlr_jump(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "can't convert %s to int", mp_obj_get_type_str(arg)));
203207
}

0 commit comments

Comments
 (0)