objnamedtuple: Accept field list as a string.
This change is required to unbreak some CPython stdlib modules (as included into micropython-lib).
This commit is contained in:
parent
8705171233
commit
44cd46a7e4
|
@ -30,6 +30,7 @@
|
|||
#include "py/nlr.h"
|
||||
#include "py/objtuple.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/objstr.h"
|
||||
|
||||
#if MICROPY_PY_COLLECTIONS
|
||||
|
||||
|
@ -169,6 +170,11 @@ STATIC mp_obj_t new_namedtuple_type(mp_obj_t name_in, mp_obj_t fields_in) {
|
|||
qstr name = mp_obj_str_get_qstr(name_in);
|
||||
mp_uint_t n_fields;
|
||||
mp_obj_t *fields;
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
if (MP_OBJ_IS_STR(fields_in)) {
|
||||
fields_in = mp_obj_str_split(1, &fields_in);
|
||||
}
|
||||
#endif
|
||||
if (!MP_OBJ_IS_TYPE(fields_in, &mp_type_list)) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "list required"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue