mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 12:10:13 +01:00
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:
@@ -1,3 +1,5 @@
|
|||||||
|
# This tests checks the behaviour of the `check_esp_err`/`check_esp_err_` C function.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from esp32 import Partition as p
|
from esp32 import Partition as p
|
||||||
import micropython
|
import micropython
|
||||||
@@ -23,6 +25,7 @@ except OSError as e:
|
|||||||
|
|
||||||
# same but with out of memory condition by locking the heap
|
# same but with out of memory condition by locking the heap
|
||||||
exc = "FAILED TO RAISE"
|
exc = "FAILED TO RAISE"
|
||||||
|
e = None # preallocate entry in globals dict
|
||||||
micropython.heap_lock()
|
micropython.heap_lock()
|
||||||
try:
|
try:
|
||||||
fun(part)
|
fun(part)
|
||||||
@@ -34,6 +37,7 @@ print("exc:", exc) # exc empty due to no memory
|
|||||||
# same again but having an emergency buffer
|
# same again but having an emergency buffer
|
||||||
micropython.alloc_emergency_exception_buf(256)
|
micropython.alloc_emergency_exception_buf(256)
|
||||||
exc = "FAILED TO RAISE"
|
exc = "FAILED TO RAISE"
|
||||||
|
e = None # preallocate entry in globals dict
|
||||||
micropython.heap_lock()
|
micropython.heap_lock()
|
||||||
try:
|
try:
|
||||||
fun(part)
|
fun(part)
|
||||||
|
|||||||
Reference in New Issue
Block a user