diff options
author | Dave Hylands <dhylands@gmail.com> | 2014-03-30 21:06:50 -0700 |
---|---|---|
committer | Dave Hylands <dhylands@gmail.com> | 2014-04-01 01:17:33 -0700 |
commit | baf6f14deb567ab626c1b05213af346108f41700 (patch) | |
tree | dc531b159f6e5d3c3940e5fad752df9692e4ec60 /py/obj.c | |
parent | e44d26ae0c1b5d248fa4db112cdeabe404944f3c (diff) | |
download | micropython-baf6f14deb567ab626c1b05213af346108f41700.tar.gz micropython-baf6f14deb567ab626c1b05213af346108f41700.zip |
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
Diffstat (limited to 'py/obj.c')
-rw-r--r-- | py/obj.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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))); } |