Skip to content

Commit

Permalink
Add awaiter pointer to 3.12
Browse files Browse the repository at this point in the history
Summary:
There's a good chance we're going to need to forward port the async stack walking implementation
in 3.10 to 3.12. That relies on the presence of the awaiter pointer in coroutines (and we'd like
to support async generators too). Let's get this in early, even if we don't end up needing it,
since it's an ABI breaking change.

Reviewed By: DinoV

Differential Revision: D56263282

fbshipit-source-id: 5539cdb6713beeb8374b473f82e0b227e5f65729
  • Loading branch information
mpage authored and facebook-github-bot committed Apr 18, 2024
1 parent 23c541e commit 34709a9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Include/cpython/genobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ extern "C" {
PyObject *prefix##_qualname; \
_PyErr_StackItem prefix##_exc_state; \
PyObject *prefix##_origin_or_finalizer; \
/* The awaiter (a coroutine or async generator), if any, if this is a \
coroutine or async generator */ \
PyObject *prefix##_ci_awaiter; \
char prefix##_hooks_inited; \
char prefix##_closed; \
char prefix##_running_async; \
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ def bar(cls):
check(bar, size('PP'))
# generator
def get_gen(): yield 1
check(get_gen(), size('PP4P4c7P2ic??2P'))
check(get_gen(), size('PP5P4c7P2ic??2P'))
# iterator
check(iter('abc'), size('lP'))
# callable-iterator
Expand Down
1 change: 1 addition & 0 deletions Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ gen_new_with_qualname(PyTypeObject *type, PyFrameObject *f,
gen->gi_qualname = Py_NewRef(qualname);
else
gen->gi_qualname = Py_NewRef(_PyGen_GetCode(gen)->co_qualname);
gen->gi_ci_awaiter = NULL;
_PyObject_GC_TRACK(gen);
return (PyObject *)gen;
}
Expand Down

0 comments on commit 34709a9

Please sign in to comment.