bpo-43770: _PyTypes_Init() inits _PyAnextAwaitable_Type (GH-25266)

* Rename PyAnextAwaitable_Type to _PyAnextAwaitable_Type.
* Expose the type in the internal C API.
This commit is contained in:
Victor Stinner 2021-04-08 09:58:15 +02:00 committed by GitHub
parent 453074c8da
commit b98eba5bc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -7,6 +7,9 @@ extern "C" {
PyAPI_DATA(PyTypeObject) PySeqIter_Type; PyAPI_DATA(PyTypeObject) PySeqIter_Type;
PyAPI_DATA(PyTypeObject) PyCallIter_Type; PyAPI_DATA(PyTypeObject) PyCallIter_Type;
#ifdef Py_BUILD_CORE
extern PyTypeObject _PyAnextAwaitable_Type;
#endif
#define PySeqIter_Check(op) Py_IS_TYPE(op, &PySeqIter_Type) #define PySeqIter_Check(op) Py_IS_TYPE(op, &PySeqIter_Type)

View File

@ -333,7 +333,7 @@ static PyAsyncMethods anextawaitable_as_async = {
0, /* am_send */ 0, /* am_send */
}; };
PyTypeObject PyAnextAwaitable_Type = { PyTypeObject _PyAnextAwaitable_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) PyVarObject_HEAD_INIT(&PyType_Type, 0)
"anext_awaitable", /* tp_name */ "anext_awaitable", /* tp_name */
sizeof(anextawaitableobject), /* tp_basicsize */ sizeof(anextawaitableobject), /* tp_basicsize */
@ -369,7 +369,7 @@ PyObject *
PyAnextAwaitable_New(PyObject *awaitable, PyObject *default_value) PyAnextAwaitable_New(PyObject *awaitable, PyObject *default_value)
{ {
anextawaitableobject *anext = PyObject_GC_New( anextawaitableobject *anext = PyObject_GC_New(
anextawaitableobject, &PyAnextAwaitable_Type); anextawaitableobject, &_PyAnextAwaitable_Type);
if (anext == NULL) { if (anext == NULL) {
return NULL; return NULL;
} }

View File

@ -1833,6 +1833,7 @@ _PyTypes_Init(void)
INIT_TYPE(PyUnicode_Type); INIT_TYPE(PyUnicode_Type);
INIT_TYPE(PyWrapperDescr_Type); INIT_TYPE(PyWrapperDescr_Type);
INIT_TYPE(Py_GenericAliasType); INIT_TYPE(Py_GenericAliasType);
INIT_TYPE(_PyAnextAwaitable_Type);
INIT_TYPE(_PyAsyncGenASend_Type); INIT_TYPE(_PyAsyncGenASend_Type);
INIT_TYPE(_PyAsyncGenAThrow_Type); INIT_TYPE(_PyAsyncGenAThrow_Type);
INIT_TYPE(_PyAsyncGenWrappedValue_Type); INIT_TYPE(_PyAsyncGenWrappedValue_Type);