py: Make sure getattr() works with non-interned strings (by interning them).

This commit is contained in:
Paul Sokolovsky
2014-06-08 01:13:35 +03:00
parent d31a093f9c
commit b4efac14cd
4 changed files with 14 additions and 2 deletions

View File

@@ -1751,6 +1751,11 @@ mp_obj_t mp_obj_new_str(const char* data, uint len, bool make_qstr_if_not_alread
}
}
mp_obj_t mp_obj_str_intern(mp_obj_t str) {
GET_STR_DATA_LEN(str, data, len);
return MP_OBJ_NEW_QSTR(qstr_from_strn((const char*)data, len));
}
mp_obj_t mp_obj_new_bytes(const byte* data, uint len) {
return mp_obj_new_str_of_type(&mp_type_bytes, data, len);
}