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
|
||||
mp_obj_dict_t *globals = mp_globals_get();
|
||||
mp_obj_dict_t *locals = mp_locals_get();
|
||||
if (n_args > 1) {
|
||||
globals = MP_OBJ_TO_PTR(args[1]);
|
||||
if (n_args > 2) {
|
||||
locals = MP_OBJ_TO_PTR(args[2]);
|
||||
} else {
|
||||
locals = globals;
|
||||
for (size_t i = 1; i < 3 && i < n_args; ++i) {
|
||||
if (args[i] != mp_const_none) {
|
||||
if (!MP_OBJ_IS_TYPE(args[i], &mp_type_dict)) {
|
||||
mp_raise_TypeError(NULL);
|
||||
}
|
||||
locals = MP_OBJ_TO_PTR(args[i]);
|
||||
if (i == 1) {
|
||||
globals = locals;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue