From: whitequark Date: Thu, 27 Aug 2020 07:11:14 +0000 (+0000) Subject: sim._pycoro: make src_loc() more robust. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=432ef66063fe5e0fb45dafcf766a7a22a67e5280;p=nmigen.git sim._pycoro: make src_loc() more robust. * Guard for finished coroutines. * Guard for coroutines yielding from iterators and not generators. --- 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