From eb88803ac859db07726481501aea5c0e6bbf3705 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 9 May 2018 16:15:02 +1000 Subject: [PATCH] py/{modbuiltins,repl}: Start qstr probing from after empty qstr. The list of qstrs starts with MP_QSTR_NULL followed by MP_QSTR_, and these should never appear in dir() or REPL tab completion, so skip them. --- py/modbuiltins.c | 2 +- py/repl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/py/modbuiltins.c b/py/modbuiltins.c index 5d4ec8ffe4..e45c714e9b 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -186,7 +186,7 @@ STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) { // Make a list of names in the given object // Implemented by probing all possible qstrs with mp_load_method_maybe size_t nqstr = QSTR_TOTAL(); - for (size_t i = 1; i < nqstr; ++i) { + for (size_t i = MP_QSTR_ + 1; i < nqstr; ++i) { mp_obj_t dest[2]; mp_load_method_maybe(args[0], i, dest); if (dest[0] != MP_OBJ_NULL) { diff --git a/py/repl.c b/py/repl.c index 61ae2c1fef..56b1db0115 100644 --- a/py/repl.c +++ b/py/repl.c @@ -176,7 +176,7 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print const char *match_str = NULL; size_t match_len = 0; qstr q_first = 0, q_last; - for (qstr q = 1; q < nqstr; ++q) { + for (qstr q = MP_QSTR_ + 1; q < nqstr; ++q) { size_t d_len; const char *d_str = (const char*)qstr_data(q, &d_len); if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {