blob: 17e3e1262472c9b727192387b520c6c5b7908928 (
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
29
30
31
32
33
34
|
# test handling of failed heap allocation with memoryview
try:
import micropython
micropython.heap_lock
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
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()
|