Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
gh-120321: Add gi_state, cr_state, and ag_state attributes#144409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
f3335d386c06fa71a9532be2572059a219bb7fb695File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -262,6 +262,12 @@ attributes (see :ref:`import-mod-attrs` for module attributes): | ||
| | | | ``yield from``, or | | ||
| | | | ``None`` | | ||
| +-----------------+-------------------+---------------------------+ | ||
| | | gi_state | state of the generator, | | ||
| | | | one of ``GEN_CREATED``, | | ||
| | | | ``GEN_RUNNING``, | | ||
| | | | ``GEN_SUSPENDED``, or | | ||
| | | | ``GEN_CLOSED`` | | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Please add a | ||
| +-----------------+-------------------+---------------------------+ | ||
| | async generator | __name__ | name | | ||
| +-----------------+-------------------+---------------------------+ | ||
| | | __qualname__ | qualified name | | ||
| @@ -278,6 +284,13 @@ attributes (see :ref:`import-mod-attrs` for module attributes): | ||
| +-----------------+-------------------+---------------------------+ | ||
| | | ag_code | code | | ||
| +-----------------+-------------------+---------------------------+ | ||
| | | ag_state | state of the async | | ||
| | | | generator, one of | | ||
| | | | ``AGEN_CREATED``, | | ||
| | | | ``AGEN_RUNNING``, | | ||
| | | | ``AGEN_SUSPENDED``, or | | ||
| | | | ``AGEN_CLOSED`` | | ||
| +-----------------+-------------------+---------------------------+ | ||
| | coroutine | __name__ | name | | ||
| +-----------------+-------------------+---------------------------+ | ||
| | | __qualname__ | qualified name | | ||
| @@ -298,6 +311,12 @@ attributes (see :ref:`import-mod-attrs` for module attributes): | ||
| | | | created, or ``None``. See | | ||
| | | | |coroutine-origin-link| | | ||
| +-----------------+-------------------+---------------------------+ | ||
| | | cr_state | state of the coroutine, | | ||
| | | | one of ``CORO_CREATED``, | | ||
| | | | ``CORO_RUNNING``, | | ||
| | | | ``CORO_SUSPENDED``, or | | ||
| | | | ``CORO_CLOSED`` | | ||
| +-----------------+-------------------+---------------------------+ | ||
| | builtin | __doc__ | documentation string | | ||
| +-----------------+-------------------+---------------------------+ | ||
| | | __name__ | original name of this | | ||
| @@ -341,6 +360,11 @@ attributes (see :ref:`import-mod-attrs` for module attributes): | ||
| Add ``f_generator`` attribute to frames. | ||
| .. versionchanged:: next | ||
| Add ``gi_state`` attribute to generators, ``cr_state`` attribute to | ||
| coroutines, and ``ag_state`` attribute to async generators. | ||
| .. function:: getmembers(object[, predicate]) | ||
| Return all the members of an object in a list of ``(name, value)`` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -44,18 +44,16 @@ extern PyFrameObject* _PyFrame_New_NoTrack(PyCodeObject *code); | ||
| /* other API */ | ||
| typedef enum _framestate { | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Don't forget to mention FRAME_COMPLETED removal in the commit message. I'm fine with the removal, the constant was only used in one place: in FRAME_STATE_FINISHED(). ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I've edited the PR description and will use that when squash + merging. | ||
| FRAME_CREATED = 0, | ||
| FRAME_SUSPENDED = 1, | ||
| FRAME_SUSPENDED_YIELD_FROM = 2, | ||
| FRAME_SUSPENDED_YIELD_FROM_LOCKED = 3, | ||
| FRAME_EXECUTING = 4, | ||
| FRAME_CLEARED = 5 | ||
| } PyFrameState; | ||
| #define FRAME_STATE_SUSPENDED(S) ((S) >= FRAME_SUSPENDED && (S) <= FRAME_SUSPENDED_YIELD_FROM_LOCKED) | ||
| #define FRAME_STATE_FINISHED(S) ((S) == FRAME_CLEARED) | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Add ``gi_state``, ``cr_state``, and ``ag_state`` attributes to generators, | ||
| coroutines, and async generators that return the current state as a string | ||
| (e.g., ``GEN_RUNNING``). The:mod:`inspect` module functions | ||
| :func:`~inspect.getgeneratorstate`,:func:`~inspect.getcoroutinestate`, and | ||
| :func:`~inspect.getasyncgenstate` now return these attributes directly. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.