diff options
| author | Scott Shawcroft <scott@adafruit.com> | 2020-05-12 11:40:49 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-12 11:40:49 -0700 |
| commit | a1091bbfbbb1b35c2e685fa874cc2caf7020740b (patch) | |
| tree | d3fccbc7b3716aa53e6c06e18fa29dd64461e6a8 /shared-bindings | |
| parent | 6c5874c5a50addfb9e28a070131122e6442b9622 (diff) | |
| parent | 4712f9f1048612d92c0731dcee30fbd08a64263f (diff) | |
Merge pull request #2871 from DavePutz/Issue2812
Throw a NotImplementedError for time functions on boards without long ints
Diffstat (limited to 'shared-bindings')
| -rw-r--r-- | shared-bindings/time/__init__.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 8d7f2f3fd..ef75a23bd 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -188,6 +188,14 @@ void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm) { tm->tm_yday = mp_obj_get_int(elems[7]); // elems[8] tm_isdst is not supported } +#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE +// Function to return a NotImplementedError on platforms that don't +// support long integers +STATIC mp_obj_t time_not_implemented(void) { + mp_raise_NotImplementedError(translate("No long integer support")); +} +MP_DEFINE_CONST_FUN_OBJ_0(time_not_implemented_obj, time_not_implemented); +#endif #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE mp_obj_t MP_WEAK rtc_get_time_source_time(void) { @@ -307,6 +315,12 @@ STATIC const mp_rom_map_elem_t time_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&time_time_obj) }, { MP_ROM_QSTR(MP_QSTR_monotonic_ns), MP_ROM_PTR(&time_monotonic_ns_obj) }, #endif + #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE + { MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&time_not_implemented_obj) }, + { MP_ROM_QSTR(MP_QSTR_mktime), MP_ROM_PTR(&time_not_implemented_obj) }, + { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&time_not_implemented_obj) }, + { MP_ROM_QSTR(MP_QSTR_monotonic_ns), MP_ROM_PTR(&time_not_implemented_obj) }, + #endif }; STATIC MP_DEFINE_CONST_DICT(time_module_globals, time_module_globals_table); |
