summaryrefslogtreecommitdiff
path: root/tests/micropython/emg_exc.py
blob: d228e6faab856e22fa655e1bd84ecf2c982114b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# test that emergency exceptions work

import micropython
import sys

# some ports need to allocate heap for the emg exc
try:
    micropython.alloc_emergency_exception_buf(256)
except AttributeError:
    pass

def f():
    micropython.heap_lock()
    try:
        raise ValueError(1)
    except ValueError as er:
        sys.print_exception(er)
    micropython.heap_unlock()

f()