Skip to content

Commit eb88803

Browse files
committed
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.
1 parent c1115d9 commit eb88803

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

py/modbuiltins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ STATIC mp_obj_t mp_builtin_dir(size_t n_args, const mp_obj_t *args) {
186186
// Make a list of names in the given object
187187
// Implemented by probing all possible qstrs with mp_load_method_maybe
188188
size_t nqstr = QSTR_TOTAL();
189-
for (size_t i = 1; i < nqstr; ++i) {
189+
for (size_t i = MP_QSTR_ + 1; i < nqstr; ++i) {
190190
mp_obj_t dest[2];
191191
mp_load_method_maybe(args[0], i, dest);
192192
if (dest[0] != MP_OBJ_NULL) {

py/repl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ size_t mp_repl_autocomplete(const char *str, size_t len, const mp_print_t *print
176176
const char *match_str = NULL;
177177
size_t match_len = 0;
178178
qstr q_first = 0, q_last;
179-
for (qstr q = 1; q < nqstr; ++q) {
179+
for (qstr q = MP_QSTR_ + 1; q < nqstr; ++q) {
180180
size_t d_len;
181181
const char *d_str = (const char*)qstr_data(q, &d_len);
182182
if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {

0 commit comments

Comments
 (0)