tests/ports/esp32/check_err_str.py: Preallocate global variable.

This test fails on all esp32 boards without this fix, because the
try/except that runs with the heap locked attempts to increase the size of
the globals dict when assigning to the exception variable `e`.

Fix that by preallocating the global variable `e`.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2025-12-10 12:39:01 +11:00
parent 53052857e2
commit b78fac161e

View File

@@ -1,3 +1,5 @@
# This tests checks the behaviour of the `check_esp_err`/`check_esp_err_` C function.
try:
from esp32 import Partition as p
import micropython
@@ -23,6 +25,7 @@ except OSError as e:
# same but with out of memory condition by locking the heap
exc = "FAILED TO RAISE"
e = None # preallocate entry in globals dict
micropython.heap_lock()
try:
fun(part)
@@ -34,6 +37,7 @@ print("exc:", exc) # exc empty due to no memory
# same again but having an emergency buffer
micropython.alloc_emergency_exception_buf(256)
exc = "FAILED TO RAISE"
e = None # preallocate entry in globals dict
micropython.heap_lock()
try:
fun(part)