Merge pull request #7566 from jepler/chain-exception-fix
Fix several places where an exception could be chained wrongly
This commit is contained in:
commit
7071478992
@ -155,6 +155,12 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin
|
||||
mp_obj_tuple_print(print, MP_OBJ_FROM_PTR(o->args), kind);
|
||||
}
|
||||
|
||||
void mp_obj_exception_initialize0(mp_obj_exception_t *o_exc, const mp_obj_type_t *type) {
|
||||
o_exc->base.type = type;
|
||||
o_exc->args = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj;
|
||||
mp_obj_exception_clear_traceback(o_exc);
|
||||
}
|
||||
|
||||
mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||
mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false);
|
||||
|
||||
@ -583,6 +589,12 @@ void mp_obj_exception_clear_traceback(mp_obj_t self_in) {
|
||||
// just set the traceback to the empty traceback object
|
||||
// we don't want to call any memory management functions here
|
||||
self->traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj;
|
||||
#if MICROPY_CPYTHON_EXCEPTION_CHAIN
|
||||
self->cause = 0;
|
||||
self->context = 0;
|
||||
self->suppress_context = false;
|
||||
self->marked = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block) {
|
||||
|
@ -43,6 +43,7 @@ typedef struct _mp_obj_exception_t {
|
||||
|
||||
void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind);
|
||||
void mp_obj_exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
|
||||
void mp_obj_exception_initialize0(mp_obj_exception_t *o_exc, const mp_obj_type_t *type);
|
||||
mp_obj_exception_t *mp_obj_exception_get_native(mp_obj_t self_in);
|
||||
|
||||
#define MP_DEFINE_EXCEPTION(exc_name, base_name) \
|
||||
|
@ -40,10 +40,11 @@
|
||||
// Instance of GeneratorExit exception - needed by generator.close()
|
||||
#if MICROPY_CONST_GENERATOREXIT_OBJ
|
||||
const
|
||||
mp_obj_exception_t mp_static_GeneratorExit_obj = {{&mp_type_GeneratorExit}, (mp_obj_tuple_t *)&mp_const_empty_tuple_obj, (mp_obj_traceback_t *)&mp_const_empty_traceback_obj};
|
||||
#else
|
||||
static
|
||||
mp_obj_exception_t mp_static_GeneratorExit_obj;
|
||||
#endif
|
||||
mp_obj_exception_t mp_static_GeneratorExit_obj = {{&mp_type_GeneratorExit}, (mp_obj_tuple_t *)&mp_const_empty_tuple_obj, (mp_obj_traceback_t *)&mp_const_empty_traceback_obj};
|
||||
|
||||
/******************************************************************************/
|
||||
/* generator wrapper */
|
||||
@ -370,9 +371,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gen_instance_throw_obj, 2, 4, gen_ins
|
||||
static mp_obj_t generatorexit(void) {
|
||||
#if MICROPY_CPYTHON_EXCEPTION_CHAIN
|
||||
MP_STATIC_ASSERT(!MICROPY_CONST_GENERATOREXIT_OBJ);
|
||||
mp_static_GeneratorExit_obj.context = NULL;
|
||||
mp_static_GeneratorExit_obj.cause = NULL;
|
||||
mp_static_GeneratorExit_obj.suppress_context = false;
|
||||
mp_obj_exception_initialize0(&mp_static_GeneratorExit_obj, &mp_type_GeneratorExit);
|
||||
#endif
|
||||
return MP_OBJ_FROM_PTR(&mp_static_GeneratorExit_obj);
|
||||
}
|
||||
|
@ -78,14 +78,10 @@ void mp_init(void) {
|
||||
|
||||
#if MICROPY_KBD_EXCEPTION
|
||||
// initialise the exception object for raising KeyboardInterrupt
|
||||
MP_STATE_VM(mp_kbd_exception).base.type = &mp_type_KeyboardInterrupt;
|
||||
MP_STATE_VM(mp_kbd_exception).args = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj;
|
||||
MP_STATE_VM(mp_kbd_exception).traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj;
|
||||
mp_obj_exception_initialize0(&MP_STATE_VM(mp_kbd_exception), &mp_type_KeyboardInterrupt);
|
||||
#endif
|
||||
|
||||
MP_STATE_VM(mp_reload_exception).base.type = &mp_type_ReloadException;
|
||||
MP_STATE_VM(mp_reload_exception).args = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj;
|
||||
MP_STATE_VM(mp_reload_exception).traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj;
|
||||
mp_obj_exception_initialize0(&MP_STATE_VM(mp_reload_exception), &mp_type_ReloadException);
|
||||
|
||||
// call port specific initialization if any
|
||||
#ifdef MICROPY_PORT_INIT_FUNC
|
||||
|
@ -10,6 +10,7 @@ import subprocess
|
||||
import sys
|
||||
import sh
|
||||
import base64
|
||||
from io import StringIO
|
||||
from datetime import date
|
||||
from sh.contrib import git
|
||||
|
||||
@ -58,9 +59,13 @@ def get_languages(list_all=False):
|
||||
|
||||
def get_version_info():
|
||||
version = None
|
||||
sha = git("rev-parse", "--short", "HEAD").stdout.decode("utf-8")
|
||||
buffer = StringIO()
|
||||
git("rev-parse", "--short", "HEAD", _out=buffer)
|
||||
sha = buffer.getvalue().strip()
|
||||
try:
|
||||
version = git("describe", "--tags", "--exact-match").stdout.decode("utf-8").strip()
|
||||
buffer = StringIO()
|
||||
git("describe", "--tags", "--exact-match", _out=buffer)
|
||||
version = buffer.getvalue().strip()
|
||||
except sh.ErrorReturnCode_128:
|
||||
# No exact match
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user