From 9930bc151a9edec967d7ff36417690e1ce7bd792 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 11 Oct 2023 14:43:14 -0700 Subject: [PATCH] Fix skipped test --- extmod/moduasyncio.c | 9 +++++++-- tests/extmod/uasyncio_task_exception.py | 5 ----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extmod/moduasyncio.c b/extmod/moduasyncio.c index 270faebffc..80e673c94a 100644 --- a/extmod/moduasyncio.c +++ b/extmod/moduasyncio.c @@ -294,8 +294,13 @@ STATIC mp_obj_t task_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) { STATIC mp_obj_t task_iternext(mp_obj_t self_in) { mp_obj_task_t *self = MP_OBJ_TO_PTR(self_in); if (TASK_IS_DONE(self)) { - // Task finished, raise return value to caller so it can continue. - nlr_raise(self->data); + if (self->data == mp_const_none) { + // Task finished but has already been sent to the loop's exception handler. + mp_raise_StopIteration(MP_OBJ_NULL); + } else { + // Task finished, raise return value to caller so it can continue. + nlr_raise(self->data); + } } else { // Put calling task on waiting queue. mp_obj_t cur_task = mp_obj_dict_get(uasyncio_context, MP_OBJ_NEW_QSTR(MP_QSTR_cur_task)); diff --git a/tests/extmod/uasyncio_task_exception.py b/tests/extmod/uasyncio_task_exception.py index b364251734..9fb26857b5 100644 --- a/tests/extmod/uasyncio_task_exception.py +++ b/tests/extmod/uasyncio_task_exception.py @@ -7,10 +7,6 @@ # If the task _is_ subsequently awaited, then the await should succeed without # raising. -# TODO: Fix this test. -print("SKIP") -raise SystemExit - try: import asyncio except ImportError: @@ -38,7 +34,6 @@ async def main(): await asyncio.sleep(0) print("await") await t # should not raise. - print("await done") asyncio.run(main())