Commit 5b401954 authored by Stefan Behnel's avatar Stefan Behnel

add a compile test for github issue #1692: raising StopAsyncIteration without...

add a compile test for github issue #1692: raising StopAsyncIteration without using "await" was missing utility code and failed to compile
parent 4b711c56
# mode: compile
# tag: pep492
# make sure async iterators also compile correctly without using 'await'
cdef class AsyncIter:
cdef long i
cdef long aiter_calls
cdef long max_iter_calls
def __init__(self, long max_iter_calls=1):
self.i = 0
self.aiter_calls = 0
self.max_iter_calls = max_iter_calls
def __aiter__(self):
self.aiter_calls += 1
return self
async def __anext__(self):
self.i += 1
assert self.aiter_calls <= self.max_iter_calls
if self.i > 10:
raise StopAsyncIteration
return self.i, self.i
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment