objstr: Implement "%(key)s" % {} formatting for strings and dicts.

Also, make sure that args to "*" format specifiers are bounds-checked
properly and don't lead for segfaults in case of mismatch.
This commit is contained in:
Paul Sokolovsky
2014-06-05 20:02:15 +03:00
parent 1e82ef3ae8
commit 75ce9256b2
5 changed files with 76 additions and 17 deletions

View File

@@ -163,16 +163,6 @@ void do_load(mp_obj_t module_obj, vstr_t *file) {
mp_globals_set(old_globals);
}
// TODO: Move to objdict?
STATIC inline mp_obj_t mp_obj_dict_get(mp_obj_t dict_in, mp_obj_t key) {
mp_obj_dict_t *dict = dict_in;
mp_map_elem_t *elem = mp_map_lookup(&dict->map, key, MP_MAP_LOOKUP);
if (elem == NULL) {
return elem;
}
return elem->value;
}
mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
#if DEBUG_PRINT
printf("__import__:\n");