From c00219d9f3bd76f406ffa3cacb9768a1468b1452 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 27 Aug 2020 07:11:14 +0000 Subject: [PATCH] sim._pycoro: make src_loc() more robust. * Guard for finished coroutines. * Guard for coroutines yielding from iterators and not generators. --- nmigen/sim/_pycoro.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nmigen/sim/_pycoro.py b/nmigen/sim/_pycoro.py index 0421d57..dbd7601 100644 --- a/nmigen/sim/_pycoro.py +++ b/nmigen/sim/_pycoro.py @@ -32,7 +32,9 @@ class PyCoroProcess(Process): def src_loc(self): coroutine = self.coroutine - while coroutine.gi_yieldfrom is not None: + if coroutine is None: + return None + while coroutine.gi_yieldfrom is not None and inspect.isgenerator(coroutine.gi_yieldfrom): coroutine = coroutine.gi_yieldfrom if inspect.isgenerator(coroutine): frame = coroutine.gi_frame -- 2.30.2