8000 WIP updates to work after rebase · micropython/micropython@c5da53f · GitHub
[go: up one dir, main page]

Skip to content

Commit c5da53f

Browse files
committed
WIP updates to work after rebase
1 parent b00107a commit c5da53f

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

py/builtinimport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
337337
}
338338

339339
if (mod_len == 0) {
340-
mp_raise_ValueError(NULL);
340+
return mp_raise_ValueError_o(NULL);
341341
}
342342

343343
// check if module already exists

py/objgenerator.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_
163163

164164
// Ensure the generator cannot be reentered during execution
165165
if (self->pend_exc == MP_OBJ_NULL) {
166-
mp_raise_ValueError("generator already executing");
166+
mp_raise_ValueError_o("generator already executing");
167+
*ret_val = MP_OBJ_FROM_PTR(MP_STATE_THREAD(active_exception));
168+
MP_STATE_THREAD(active_exception) = NULL;
169+
return MP_VM_RETURN_EXCEPTION;
167170
}
168171

169172
#if MICROPY_PY_GENERATOR_PEND_THROW

py/objstr.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,10 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
10991099
const char *lookup;
11001100
for (lookup = field_name; lookup < field_name_top && *lookup != '.' && *lookup != '['; lookup++);
11011101
mp_obj_t field_q = mp_obj_new_str_via_qstr(field_name, lookup - field_name); // should it be via qstr?
1102+
if (field_q == MP_OBJ_NULL) {
1103+
vstr.buf = NULL;
1104+
return vstr;
1105+
}
11021106
field_name = lookup;
11031107
mp_map_elem_t *key_elem = mp_map_lookup(kwargs, field_q, MP_MAP_LOOKUP);
11041108
if (key_elem == NULL) {
@@ -1498,6 +1502,9 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_
14981502
++str;
14991503
}
15001504
mp_obj_t k_obj = mp_obj_new_str_via_qstr((const char*)key, str - key);
1505+
if (k_obj == MP_OBJ_NULL) {
1506+
return MP_OBJ_NULL;
1507+
}
15011508
arg = mp_obj_dict_get(dict, k_obj);
15021509
if (arg == MP_OBJ_NULL) {
15031510
return MP_OBJ_NULL;
@@ -2095,7 +2102,12 @@ mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, siz
20952102

20962103
// Create a str using a qstr to store the data; may use existing or new qstr.
20972104
mp_obj_t mp_obj_new_str_via_qstr(const char* data, size_t len) {
2098-
return MP_OBJ_NEW_QSTR(qstr_from_strn(data, len));
2105+
qstr qst = qstr_from_strn(data, len);
2106+
if (qst == MP_QSTRnull) {
2107+
return MP_OBJ_NULL;
2108+
} else {
2109+
return MP_OBJ_NEW_QSTR(qst);
2110+
}
20992111
}
21002112

21012113
// Create a str/bytes object from the given vstr. The vstr buffer is resized to

py/qstr.c

Lines changed: 2 additions & 1 deletion
755D
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ qstr qstr_from_strn(const char *str, size_t len) {
202202
// check that len is not too big
203203
if (len >= (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN))) {
204204
QSTR_EXIT();
205-
mp_raise_msg(&mp_type_RuntimeError, "name too long");
205+
mp_raise_msg_o(&mp_type_RuntimeError, "name too long");
206+
return MP_QSTRnull;
206207
}
207208

208209
// compute number of bytes needed to intern this string

0 commit comments

Comments
 (0)
0