diff options
| author | Dan Halbert <halbert@halwitz.org> | 2017-08-25 22:17:07 -0400 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2017-08-25 22:17:07 -0400 |
| commit | ef61b5ecb59e9b4e37e3e3c023c62d583c23eb16 (patch) | |
| tree | 45a798fbed0dc673304597b29e0b60174195ce79 /py/runtime.c | |
| parent | 266be307770abe11c220eb493388807920914b7a (diff) | |
| parent | 1f78e7a43130acfa4bedf16c1007a1b0f37c75c3 (diff) | |
Initial merge of micropython v1.9.2 into circuitpython 2.0.0 (in development) master.
cpx build compiles and loads and works in repl; test suite not run yet
esp8266 not tested yet
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); +} |
