Skip to content

Commit 73fc021

Browse files
authored
Merge pull request micropython#8993 from tannewt/tab_complete_warnings
Disable warnings during REPL autocomplete
2 parents 0d2e62f + f7945aa commit 73fc021

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

py/repl.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333

3434
#if MICROPY_HELPER_REPL
3535

36+
// CIRCUITPY-CHANGE: Disable warnings during autocomplete.
37+
#if CIRCUITPY_WARNINGS
38+
#include "shared-bindings/warnings/__init__.h"
39+
#endif
40+
3641
#if MICROPY_PY_SYS_PS1_PS2
3742
const char *mp_repl_get_psx(unsigned int entry) {
3843
if (mp_obj_is_str(MP_STATE_VM(sys_mutable)[entry])) {
@@ -158,7 +163,21 @@ STATIC bool test_qstr(mp_obj_t obj, qstr name) {
158163
if (obj) {
159164
// try object member
160165
mp_obj_t dest[2];
166+
167+
// CIRCUITPY-CHANGE: Disable warnings during autocomplete. test_qstr()
168+
// pretends to load every qstr from a module and it can trigger warnings
169+
// meant to happen when user code imports them. So, save warning state and
170+
// restore it once we've found matching completions.
171+
#if CIRCUITPY_WARNINGS
172+
warnings_action_t current_action = MP_STATE_THREAD(warnings_action);
173+
MP_STATE_THREAD(warnings_action) = WARNINGS_IGNORE;
174+
#endif
175+
161176
mp_load_method_protected(obj, name, dest, true);
177+
178+
#if CIRCUITPY_WARNINGS
179+
MP_STATE_THREAD(warnings_action) = current_action;
180+
#endif
162181
return dest[0] != MP_OBJ_NULL;
163182
} else {
164183
// try builtin module

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy