py: Never intern data of large string/bytes object; add relevant tests.

Previously to this patch all constant string/bytes objects were
interned by the compiler, and this lead to crashes when the qstr was too
long (noticeable now that qstr length storage defaults to 1 byte).

With this patch, long string/bytes objects are never interned, and are
referenced directly as constant objects within generated code using
load_const_obj.
This commit is contained in:
Damien George
2015-01-13 16:21:23 +00:00
parent dab1385177
commit 4c81ba8015
5 changed files with 37 additions and 21 deletions

View File

@@ -148,6 +148,7 @@ qstr qstr_from_str(const char *str) {
}
qstr qstr_from_strn(const char *str, mp_uint_t len) {
assert(len < (1 << (8 * MICROPY_QSTR_BYTES_IN_LEN)));
qstr q = qstr_find_strn(str, len);
if (q == 0) {
mp_uint_t hash = qstr_compute_hash((const byte*)str, len);