10000 Never long live the main dictionary. · ihassin/circuitpython@5555a24 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5555a24

Browse files
committed
Never long live the main dictionary.
It's contents change often and may be referenced elsewhere. Fixes adafruit#1443
1 parent a39fc94 commit 5555a24

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

py/gc_long_lived.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "py/emitglue.h"
2828
#include "py/gc_long_lived.h"
2929
#include "py/gc.h"
30+
#include "py/mpstate.h"
3031

3132
mp_obj_fun_bc_t *make_fun_bc_long_lived(mp_obj_fun_bc_t *fun_bc, uint8_t max_depth) {
3233
#ifndef MICROPY_ENABLE_GC
@@ -88,7 +89,7 @@ mp_obj_dict_t *make_dict_long_lived(mp_obj_dict_t *dict, uint8_t max_depth) {
8889
#ifndef MICROPY_ENABLE_GC
8990
return dict;
9091
#endif
91-
if (dict == NULL || max_depth == 0) {
92+
if (dict == NULL || max_depth == 0 || dict == &MP_STATE_VM(dict_main)) {
9293
return dict;
9394
}
9495
// Don't recurse unnecessarily. Return immediately if we've already seen this dict.

0 commit comments

Comments
 (0)
0