diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2017-08-28 13:59:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-28 13:59:26 -0700 |
| commit | 447a4b1ecd5655357c9daaace03b91355d2e2c6d (patch) | |
| tree | 46ca08a93e9870aab4fbb533843f3c99796cbdf4 /py/runtime.c | |
| parent | 4e63d55d8d0df6d7600bb684fa90a8cb54708ba8 (diff) | |
| parent | c679c80c710fd4a0e37ad87200d8a721e19727aa (diff) | |
Merge pull request #208 from adafruit/merge-v1.9.2
Merge MicroPython v1.9.2
Diffstat (limited to 'py/runtime.c')
| -rw-r--r-- | py/runtime.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/py/runtime.c b/py/runtime.c index 1eb6da433..2d24f3f75 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1,5 +1,5 @@ /* - * This file is part of the Micro Python project, http://micropython.org/ + * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) * @@ -48,7 +48,7 @@ #include "py/stackctrl.h" #include "py/gc.h" -#if 0 // print debugging info +#if MICROPY_DEBUG_VERBOSE // print debugging info #define DEBUG_PRINT (1) #define DEBUG_printf DEBUG_printf #define DEBUG_OP_printf(...) DEBUG_printf(__VA_ARGS__) @@ -1077,7 +1077,7 @@ void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) { } else if (type->locals_dict != NULL) { // generic method lookup // this is a lookup in the object (ie not class or type) - assert(type->locals_dict->base.type == &mp_type_dict); // Micro Python restriction, for now + assert(type->locals_dict->base.type == &mp_type_dict); // MicroPython restriction, for now mp_map_t *locals_map = &type->locals_dict->map; mp_map_elem_t *elem = mp_map_lookup(locals_map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP); if (elem != NULL) { @@ -1476,18 +1476,15 @@ mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_i #endif // MICROPY_ENABLE_COMPILER -void *m_malloc_fail(size_t num_bytes) { +NORETURN void *m_malloc_fail(size_t num_bytes) { DEBUG_printf("memory allocation failed, allocating %u bytes\n", (uint)num_bytes); - if (0) { - // dummy #if MICROPY_ENABLE_GC - } else if (gc_is_locked()) { + if (gc_is_locked()) { mp_raise_msg(&mp_type_MemoryError, "memory allocation failed, heap is locked"); - #endif - } else { - mp_raise_msg_varg(&mp_type_MemoryError, - "memory allocation failed, allocating %u bytes", (uint)num_bytes); } + #endif + mp_raise_msg_varg(&mp_type_MemoryError, + "memory allocation failed, allocating %u bytes", (uint)num_bytes); } NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg) { @@ -1514,10 +1511,6 @@ NORETURN void mp_raise_RuntimeError(const char *msg) { mp_raise_msg(&mp_type_RuntimeError, msg); } -NORETURN void mp_raise_NotImplementedError(const char *msg) { - mp_raise_msg(&mp_type_NotImplementedError, msg); -} - NORETURN void mp_raise_ImportError(const char *msg) { mp_raise_msg(&mp_type_ImportError, msg); } @@ -1553,3 +1546,8 @@ NORETURN void mp_raise_TypeError_varg(const char *fmt, ...) { NORETURN void mp_raise_OSError(int errno_) { nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno_))); } + + +NORETURN void mp_raise_NotImplementedError(const char *msg) { + mp_raise_msg(&mp_type_NotImplementedError, msg); +} |
