sim._pycoro: make src_loc() more robust.

* Guard for finished coroutines.
  * Guard for coroutines yielding from iterators and not generators.
This commit is contained in:
whitequark 2020-08-27 07:11:14 +00:00
parent 141eaf0e40
commit c00219d9f3

View file

@ -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