py/builtinevex: Add typechecking of globals/locals args to eval/exec.
This commit is contained in:
parent
6c1b7e008d
commit
bb3bddabb5
@ -113,12 +113,15 @@ STATIC mp_obj_t eval_exec_helper(size_t n_args, const mp_obj_t *args, mp_parse_i
|
|||||||
// work out the context
|
// work out the context
|
||||||
mp_obj_dict_t *globals = mp_globals_get();
|
mp_obj_dict_t *globals = mp_globals_get();
|
||||||
mp_obj_dict_t *locals = mp_locals_get();
|
mp_obj_dict_t *locals = mp_locals_get();
|
||||||
if (n_args > 1) {
|
for (size_t i = 1; i < 3 && i < n_args; ++i) {
|
||||||
globals = MP_OBJ_TO_PTR(args[1]);
|
if (args[i] != mp_const_none) {
|
||||||
if (n_args > 2) {
|
if (!MP_OBJ_IS_TYPE(args[i], &mp_type_dict)) {
|
||||||
locals = MP_OBJ_TO_PTR(args[2]);
|
mp_raise_TypeError(NULL);
|
||||||
} else {
|
}
|
||||||
locals = globals;
|
locals = MP_OBJ_TO_PTR(args[i]);
|
||||||
|
if (i == 1) {
|
||||||
|
globals = locals;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user