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=c00219d9f3bd76f406ffa3cacb9768a1468b1452;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