blob: da2d1abffa634e56e42ebc69fe0ee4288bbd00e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# test handling of failed heap allocation with memoryview
import micropython
class GetSlice:
def __getitem__(self, idx):
return idx
sl = GetSlice()[:]
# create memoryview
micropython.heap_lock()
try:
memoryview(b"")
except MemoryError:
print("MemoryError: memoryview create")
micropython.heap_unlock()
# memoryview get with slice
m = memoryview(b"")
micropython.heap_lock()
try:
m[sl]
except MemoryError:
print("MemoryError: memoryview subscr get")
micropython.heap_unlock()
|