[Python-checkins] gh-106320: Move private _PyGen API to the internal C API (#107032)

vstinner webhook-mailer at python.org
Sat Jul 22 10:21:20 EDT 2023


https://github.com/python/cpython/commit/ae8b114c5b9d211f47bf521fcfdbf40ef72a1bac
commit: ae8b114c5b9d211f47bf521fcfdbf40ef72a1bac
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2023-07-22T14:21:16Z
summary:

gh-106320: Move private _PyGen API to the internal C API (#107032)

Move private _PyGen API to internal C API:

* _PyAsyncGenAThrow_Type
* _PyAsyncGenWrappedValue_Type
* _PyCoroWrapper_Type
* _PyGen_FetchStopIterationValue()
* _PyGen_Finalize()
* _PyGen_SetStopIterationValue()

No longer these symbols, except of the ones by the _asyncio shared
extensions.

files:
M Include/cpython/genobject.h
M Include/internal/pycore_genobject.h

diff --git a/Include/cpython/genobject.h b/Include/cpython/genobject.h
index 7856481b5db30..49e46c277d75a 100644
--- a/Include/cpython/genobject.h
+++ b/Include/cpython/genobject.h
@@ -41,9 +41,6 @@ PyAPI_DATA(PyTypeObject) PyGen_Type;
 PyAPI_FUNC(PyObject *) PyGen_New(PyFrameObject *);
 PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(PyFrameObject *,
     PyObject *name, PyObject *qualname);
-PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
-PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
-PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
 PyAPI_FUNC(PyCodeObject *) PyGen_GetCode(PyGenObject *gen);
 
 
@@ -54,7 +51,6 @@ typedef struct {
 } PyCoroObject;
 
 PyAPI_DATA(PyTypeObject) PyCoro_Type;
-PyAPI_DATA(PyTypeObject) _PyCoroWrapper_Type;
 
 #define PyCoro_CheckExact(op) Py_IS_TYPE((op), &PyCoro_Type)
 PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *,
@@ -69,8 +65,6 @@ typedef struct {
 
 PyAPI_DATA(PyTypeObject) PyAsyncGen_Type;
 PyAPI_DATA(PyTypeObject) _PyAsyncGenASend_Type;
-PyAPI_DATA(PyTypeObject) _PyAsyncGenWrappedValue_Type;
-PyAPI_DATA(PyTypeObject) _PyAsyncGenAThrow_Type;
 
 PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *,
     PyObject *name, PyObject *qualname);
diff --git a/Include/internal/pycore_genobject.h b/Include/internal/pycore_genobject.h
index dc60b4ca70511..fb63d9c3537a6 100644
--- a/Include/internal/pycore_genobject.h
+++ b/Include/internal/pycore_genobject.h
@@ -9,9 +9,20 @@ extern "C" {
 #endif
 
 extern PyObject *_PyGen_yf(PyGenObject *);
+extern void _PyGen_Finalize(PyObject *self);
+
+// _asyncio shared extensions uses _PyGen_SetStopIterationValue() and
+// _PyGen_FetchStopIterationValue()
+PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
+PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
+
 extern PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
 extern PyObject *_PyAsyncGenValueWrapperNew(PyThreadState *state, PyObject *);
 
+extern PyTypeObject _PyCoroWrapper_Type;
+extern PyTypeObject _PyAsyncGenWrappedValue_Type;
+extern PyTypeObject _PyAsyncGenAThrow_Type;
+
 /* runtime lifecycle */
 
 extern void _PyAsyncGen_Fini(PyInterpreterState *);



More information about the Python-checkins mailing list