From b4efac14cde7dca4b3fd5ded9b29e11f97621d14 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 8 Jun 2014 01:13:35 +0300 Subject: py: Make sure getattr() works with non-interned strings (by interning them). --- py/objstr.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'py/objstr.c') diff --git a/py/objstr.c b/py/objstr.c index 4e70b0081..6656090c8 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -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); } -- cgit v1.2.3