| @property |
| defgi_frame(self) ->FrameType: ... |
This issue is similar to #14780. The gi_frame property becomes None when the generator iterator completes:
>>>defgenerator_function():
... return
... yield>>>gen=generator_function()
>>>gen.gi_frame<frameat0x7f2ebe641620, file'<stdin>', line1, codegenerator_function>>>>next(gen) # consumeTraceback (mostrecentcalllast):
File"<stdin>", line1, in<module>StopIteration>>>gen.gi_frameisNoneTrue
The same applies to AsyncGeneratorType.ag_frame:
>>>asyncdefasyncgen_function():
... return
... yield>>>asyncgen=asyncgen_function()
>>>asyncgen.ag_frame<frameat0x7f37cf7d5c60, file'<stdin>', line1, codeasyncgen_function>>>> [*asyncgen.asend(None).__await__()] # consumeTraceback (mostrecentcalllast):
File"<stdin>", line1, in<module>StopAsyncIteration>>>asyncgen.ag_frameisNoneTrue
Notably, this was mentioned in both the linked issue and python/cpython#112428 (Python 3.12.1), to which it refers, but was ignored in the PR (#14802), meaning the issue was closed prematurely (why?). Moreover, none of the *_frame properties actually depend on the Python version. 3.12.0 introduced a regression, as mentioned in python/cpython#111058. The above examples (and a similar one for coroutine objects) can be easily reproduced even on Python 3.6:
Python3.6.15 (default, Apr252022, 01:55:53) [GCC9.4.0] onlinuxType"help", "copyright", "credits"or"license"formoreinformation.
>>>asyncdefcoroutine_function():
... pass>>>coro=coroutine_function()
>>>coro.cr_frame<frameobjectat0x7fe26e728a08>>>>coro.send(None) # consumeTraceback (mostrecentcalllast):
File"<stdin>", line1, in<module>StopIteration>>>coro.cr_frameisNoneTrue
typeshed/stdlib/types.pyi
Lines 402 to 403 in 7fde970
This issue is similar to #14780. The
gi_frameproperty becomesNonewhen the generator iterator completes:The same applies to
AsyncGeneratorType.ag_frame:Notably, this was mentioned in both the linked issue and python/cpython#112428 (Python 3.12.1), to which it refers, but was ignored in the PR (#14802), meaning the issue was closed prematurely (why?). Moreover, none of the
*_frameproperties actually depend on the Python version. 3.12.0 introduced a regression, as mentioned in python/cpython#111058. The above examples (and a similar one for coroutine objects) can be easily reproduced even on Python 3.6: