2020-01-28 22:27:33 -05:00
|
|
|
import micropython
|
|
|
|
|
|
|
|
# Does the full test from heapalloc_exc_compressed.py but while the heap is
|
|
|
|
# locked (this can only work when the emergency exception buf is enabled).
|
|
|
|
|
|
|
|
# Some ports need to allocate heap for the emgergency exception buffer.
|
|
|
|
try:
|
|
|
|
micropython.alloc_emergency_exception_buf(256)
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def test():
|
|
|
|
micropython.heap_lock()
|
|
|
|
|
|
|
|
try:
|
|
|
|
name()
|
|
|
|
except NameError as e:
|
|
|
|
print(type(e).__name__, e)
|
|
|
|
|
|
|
|
try:
|
2022-03-07 00:47:33 -05:00
|
|
|
raise 0
|
|
|
|
except TypeError as e:
|
2020-01-28 22:27:33 -05:00
|
|
|
print(type(e).__name__, e)
|
|
|
|
|
|
|
|
try:
|
|
|
|
name()
|
|
|
|
except NameError as e:
|
|
|
|
print(e.args[0])
|
|
|
|
|
|
|
|
try:
|
2022-03-07 00:47:33 -05:00
|
|
|
raise 0
|
|
|
|
except TypeError as e:
|
2020-01-28 22:27:33 -05:00
|
|
|
print(e.args[0])
|
|
|
|
|
|
|
|
micropython.heap_unlock()
|
|
|
|
|
|
|
|
|
|
|
|
test()
|