Skip to content

Commit 332b04b

Browse files
authored
bpo-46850: Remove _PyEval_SetAsyncGenFinalizer() (GH-32017)
Remove the following private undocumented functions from the C API: * _PyEval_GetAsyncGenFirstiter() * _PyEval_GetAsyncGenFinalizer() * _PyEval_SetAsyncGenFirstiter() * _PyEval_SetAsyncGenFinalizer() Call the public sys.get_asyncgen_hooks() and sys.set_asyncgen_hooks() functions instead.
1 parent 9d1c4d6 commit 332b04b

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

Include/cpython/ceval.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ PyAPI_DATA(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyO
99
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
1010
PyAPI_FUNC(int) _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
1111
PyAPI_FUNC(int) _PyEval_GetCoroutineOriginTrackingDepth(void);
12-
PyAPI_FUNC(int) _PyEval_SetAsyncGenFirstiter(PyObject *);
13-
PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFirstiter(void);
14-
PyAPI_FUNC(int) _PyEval_SetAsyncGenFinalizer(PyObject *);
15-
PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFinalizer(void);
1612

1713
/* Helper to look up a builtin object */
1814
PyAPI_FUNC(PyObject *) _PyEval_GetBuiltin(PyObject *);

Include/internal/pycore_ceval.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ PyAPI_FUNC(void) _PyEval_SetCoroutineOriginTrackingDepth(
3737
PyThreadState *tstate,
3838
int new_depth);
3939

40+
// Used by sys.get_asyncgen_hooks()
41+
extern PyObject* _PyEval_GetAsyncGenFirstiter(void);
42+
extern PyObject* _PyEval_GetAsyncGenFinalizer(void);
43+
44+
// Used by sys.set_asyncgen_hooks()
45+
extern int _PyEval_SetAsyncGenFirstiter(PyObject *);
46+
extern int _PyEval_SetAsyncGenFinalizer(PyObject *);
47+
4048
void _PyEval_Fini(void);
4149

4250

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Remove the following private undocumented functions from the C API:
2+
3+
* ``_PyEval_GetAsyncGenFirstiter()``
4+
* ``_PyEval_GetAsyncGenFinalizer()``
5+
* ``_PyEval_SetAsyncGenFirstiter()``
6+
* ``_PyEval_SetAsyncGenFinalizer()``
7+
8+
Call the public :func:`sys.get_asyncgen_hooks` and
9+
:func:`sys.set_asyncgen_hooks` functions instead. Patch by Victor Stinner.

Python/sysmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Data members:
1616

1717
#include "Python.h"
1818
#include "pycore_call.h" // _PyObject_CallNoArgs()
19-
#include "pycore_ceval.h" // _Py_RecursionLimitLowerWaterMark()
19+
#include "pycore_ceval.h" // _PyEval_SetAsyncGenFinalizer()
2020
#include "pycore_code.h" // _Py_QuickenedCount
2121
#include "pycore_frame.h" // _PyInterpreterFrame
2222
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()

0 commit comments

Comments
 (0)