From e02cb9ec318580497dbb17f369a61d9e932094e5 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Mon, 11 Dec 2017 11:56:20 +0200 Subject: tests/heapalloc_*: Refactor some tests to work in strict stackless mode. In strict stackless mode, it's not possible to make a function call with heap locked (because function activation record aka frame is allocated on heap). So, if the only purpose of function is to introduce local variable scope, move heap lock/unlock calls inside the function. --- tests/micropython/heapalloc_iter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/micropython/heapalloc_iter.py') diff --git a/tests/micropython/heapalloc_iter.py b/tests/micropython/heapalloc_iter.py index 79461f999..30ac82e14 100644 --- a/tests/micropython/heapalloc_iter.py +++ b/tests/micropython/heapalloc_iter.py @@ -11,8 +11,10 @@ except (ImportError, AttributeError): heap_lock = heap_unlock = lambda:0 def do_iter(l): + heap_lock() for i in l: print(i) + heap_unlock() def gen_func(): yield 1 @@ -55,7 +57,6 @@ print(sum(t)) heap_unlock() # test iterating over collections with the heap locked -heap_lock() do_iter(b'123') do_iter(ba) do_iter(ar) @@ -66,4 +67,3 @@ do_iter(s) do_iter(fs) do_iter(g1) do_iter(g2) -heap_unlock() -- cgit v1.2.3