Commit 44cd46a7 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

objnamedtuple: Accept field list as a string.

This change is required to unbreak some CPython stdlib modules (as included
into micropython-lib).
parent 87051712
......@@ -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"));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment