Title: `types.GeneratorType.gi_frame` should be `FrameType | None` · Issue #15218 · python/typeshed · GitHub
Open Graph Title: `types.GeneratorType.gi_frame` should be `FrameType | None` · Issue #15218 · python/typeshed
X Title: `types.GeneratorType.gi_frame` should be `FrameType | None` · Issue #15218 · python/typeshed
Description: typeshed/stdlib/types.pyi Lines 402 to 403 in 7fde970 @property def gi_frame(self) -> FrameType: ... This issue is similar to #14780. The gi_frame property becomes None when the generator iterator completes: >>> def generator_function():...
Open Graph Description: typeshed/stdlib/types.pyi Lines 402 to 403 in 7fde970 @property def gi_frame(self) -> FrameType: ... This issue is similar to #14780. The gi_frame property becomes None when the generator iterator ...
X Description: typeshed/stdlib/types.pyi Lines 402 to 403 in 7fde970 @property def gi_frame(self) -> FrameType: ... This issue is similar to #14780. The gi_frame property becomes None when the generator iterat...
Opengraph URL: https://github.com/python/typeshed/issues/15218
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`types.GeneratorType.gi_frame` should be `FrameType | None`","articleBody":"https://github.com/python/typeshed/blob/7fde97036f692b269cbb82ae5fd6c933064000c8/stdlib/types.pyi#L402-L403\n\nThis issue is similar to #14780. The `gi_frame` property becomes `None` when the generator iterator completes:\n\n```python\n\u003e\u003e\u003e def generator_function():\n... return\n... yield\n\u003e\u003e\u003e gen = generator_function()\n\u003e\u003e\u003e gen.gi_frame\n\u003cframe at 0x7f2ebe641620, file '\u003cstdin\u003e', line 1, code generator_function\u003e\n\u003e\u003e\u003e next(gen) # consume\nTraceback (most recent call last):\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\nStopIteration\n\u003e\u003e\u003e gen.gi_frame is None\nTrue\n```\n\nThe same applies to `AsyncGeneratorType.ag_frame`:\n\n```python\n\u003e\u003e\u003e async def asyncgen_function():\n... return\n... yield\n\u003e\u003e\u003e asyncgen = asyncgen_function()\n\u003e\u003e\u003e asyncgen.ag_frame\n\u003cframe at 0x7f37cf7d5c60, file '\u003cstdin\u003e', line 1, code asyncgen_function\u003e\n\u003e\u003e\u003e [*asyncgen.asend(None).__await__()] # consume\nTraceback (most recent call last):\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\nStopAsyncIteration\n\u003e\u003e\u003e asyncgen.ag_frame is None\nTrue\n```\n\nNotably, 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:\n\n```python\nPython 3.6.15 (default, Apr 25 2022, 01:55:53) \n[GCC 9.4.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e async def coroutine_function():\n... pass\n\u003e\u003e\u003e coro = coroutine_function()\n\u003e\u003e\u003e coro.cr_frame\n\u003cframe object at 0x7fe26e728a08\u003e\n\u003e\u003e\u003e coro.send(None) # consume\nTraceback (most recent call last):\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\nStopIteration\n\u003e\u003e\u003e coro.cr_frame is None\nTrue\n```","author":{"url":"https://github.com/x42005e1f","@type":"Person","name":"x42005e1f"},"datePublished":"2026-01-05T10:13:49.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/15218/typeshed/issues/15218"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0a0b0f77-12c1-1a4a-0464-6f2dbd1832e1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E176:B2B1:D7731F:125AE11:6A63BE20 |
| html-safe-nonce | fc7a6a0245bd566934acc194b35686a5b1570b0c84b1022751757537b1e1e2f2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMTc2OkIyQjE6RDc3MzFGOjEyNUFFMTE6NkE2M0JFMjAiLCJ2aXNpdG9yX2lkIjoiNTM1OTg4MjIwODA3NzM5NzUzNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 644656161f2158fa20aa90f65d2232bed0c49124b80a81a84f2e8a5be16d75ab |
| hovercard-subject-tag | issue:3780935529 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typeshed/15218/issue_layout |
| twitter:image | https://opengraph.githubassets.com/68989ce4285babe4bad7107e3e4fa30b0997fe0024d73461b7b6b8beff1cbbe7/python/typeshed/issues/15218 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/68989ce4285babe4bad7107e3e4fa30b0997fe0024d73461b7b6b8beff1cbbe7/python/typeshed/issues/15218 |
| og:image:alt | typeshed/stdlib/types.pyi Lines 402 to 403 in 7fde970 @property def gi_frame(self) -> FrameType: ... This issue is similar to #14780. The gi_frame property becomes None when the generator iterator ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | x42005e1f |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4c1c4f1792dfc705b5a5073fed6c61988f59766cec1277f24f55d4b876f9881c |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | fefaad6f0be5c33f57f42bb65ed668f74c872364 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width