summaryrefslogtreecommitdiff
path: root/py/objstr.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-06-08 01:13:35 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-06-08 01:15:06 +0300
commitb4efac14cde7dca4b3fd5ded9b29e11f97621d14 (patch)
treef8ff5d2331ba1ef4cd287091dad7e31651620f67 /py/objstr.c
parentd31a093f9c2bdc3c94917c928fb2cc8c26b39959 (diff)
py: Make sure getattr() works with non-interned strings (by interning them).
Diffstat (limited to 'py/objstr.c')
-rw-r--r--py/objstr.c5
1 files changed, 5 insertions, 0 deletions
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);
}