Skip to content

Commit 133045a

Browse files
committed
Add error message and guardrail
1 parent 818d1d4 commit 133045a

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

locale/circuitpython.pot

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ msgid ""
3535
"https://github.com/adafruit/circuitpython/issues\n"
3636
msgstr ""
3737

38+
#: main.c
39+
msgid ""
40+
"\n"
41+
"WARNING: Allocating pystack failed, defaulting back to build value. \n"
42+
"\n"
43+
msgstr ""
44+
45+
#: main.c
46+
msgid ""
47+
"\n"
48+
"WARNING: Invalid CIRCUITPY_PYSTACK_SIZE, defaulting back to build value.\n"
49+
"\n"
50+
msgstr ""
51+
3852
#: py/obj.c
3953
msgid " File \"%q\""
4054
msgstr ""

main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,15 @@ STATIC supervisor_allocation __attribute__ ((noinline)) * alloc_pystack(void) {
141141
(void)common_hal_os_getenv_int("CIRCUITPY_PYSTACK_SIZE", &pystack_size);
142142
// Check if value is valid
143143
if ((CIRCUITPY_PYSTACK_SIZE != pystack_size) && ((pystack_size < 384) || (pystack_size % sizeof(size_t) != 0))) {
144+
serial_write_compressed(translate("\nWARNING: Invalid CIRCUITPY_PYSTACK_SIZE, defaulting back to build value.\n\n"));
144145
pystack_size = CIRCUITPY_PYSTACK_SIZE; // Reset
145-
// TODO: Find a way to inform the user about it.
146-
// Perhaps safemode? Or is it too much?
147146
}
148147
#endif
149148
supervisor_allocation *pystack = allocate_memory(pystack_size, false, false);
149+
if (pystack == NULL) {
150+
serial_write_compressed(translate("\nWARNING: Allocating pystack failed, defaulting back to build value. \n\n"));
151+
pystack = allocate_memory(CIRCUITPY_PYSTACK_SIZE, false, false);
152+
}
150153
return pystack;
151154
}
152155
#endif

0 commit comments

Comments
 (0)