From baf6f14deb567ab626c1b05213af346108f41700 Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Sun, 30 Mar 2014 21:06:50 -0700 Subject: 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 --- py/obj.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'py/obj.c') diff --git a/py/obj.c b/py/obj.c index 95052d16d2..43863667ca 100644 --- a/py/obj.c +++ b/py/obj.c @@ -198,6 +198,10 @@ machine_int_t mp_obj_get_int(mp_obj_t arg) { return MP_OBJ_SMALL_INT_VALUE(arg); } else if (MP_OBJ_IS_TYPE(arg, &mp_type_int)) { return mp_obj_int_get_checked(arg); +#if MICROPY_ENABLE_FLOAT + } else if (MP_OBJ_IS_TYPE(arg, &mp_type_float)) { + return mp_obj_float_get(arg); +#endif } else { nlr_jump(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "can't convert %s to int", mp_obj_get_type_str(arg))); } -- cgit v1.2.3