Skip to content

Commit 8b3f912

Browse files
vstinnerasvetlov
authored andcommitted
bpo-45316: Move private functions to internal C API (GH-31579)
Move the unexported private functions to the internal C API: * pycore_frame.h: _PyFrame_New_NoTrack() * pycore_function.h: _PyFunction_GetVersionForCurrentState() * pycore_genobject.h: _PyAsyncGenValueWrapperNew() * pycore_genobject.h: _PyCoro_GetAwaitableIter() * pycore_genobject.h: _PyGen_yf()
1 parent 3215e50 commit 8b3f912

File tree

7 files changed

+18
-16
lines changed

7 files changed

+18
-16
lines changed

Include/cpython/frameobject.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ PyAPI_DATA(PyTypeObject) PyFrame_Type;
1313
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
1414
PyObject *, PyObject *);
1515

16-
/* only internal use */
17-
PyFrameObject*
18-
_PyFrame_New_NoTrack(PyCodeObject *code);
19-
20-
2116
/* The rest of the interface is specific for frame objects */
2217

2318
/* Conversions between "fast locals" and locals in dictionary */

Include/cpython/funcobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ PyAPI_FUNC(PyObject *) _PyFunction_Vectorcall(
8282
size_t nargsf,
8383
PyObject *kwnames);
8484

85-
uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func);
86-
8785
/* Macros for direct access to these values. Type checks are *not*
8886
done, so use with care. */
8987
#define PyFunction_GET_CODE(func) \

Include/cpython/genobject.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(PyFrameObject *,
4545
PyObject *name, PyObject *qualname);
4646
PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
4747
PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
48-
PyObject *_PyGen_yf(PyGenObject *);
4948
PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
5049

5150

@@ -59,7 +58,6 @@ PyAPI_DATA(PyTypeObject) PyCoro_Type;
5958
PyAPI_DATA(PyTypeObject) _PyCoroWrapper_Type;
6059

6160
#define PyCoro_CheckExact(op) Py_IS_TYPE(op, &PyCoro_Type)
62-
PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
6361
PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *,
6462
PyObject *name, PyObject *qualname);
6563

@@ -80,8 +78,6 @@ PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *,
8078

8179
#define PyAsyncGen_CheckExact(op) Py_IS_TYPE(op, &PyAsyncGen_Type)
8280

83-
PyObject *_PyAsyncGenValueWrapperNew(PyObject *);
84-
8581

8682
#undef _PyGenObject_HEAD
8783

Include/internal/pycore_frame.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ struct _frame {
1919
PyObject *_f_frame_data[1];
2020
};
2121

22+
extern PyFrameObject* _PyFrame_New_NoTrack(PyCodeObject *code);
23+
2224
/* runtime lifecycle */
2325

2426
extern void _PyFrame_Fini(PyInterpreterState *interp);

Include/internal/pycore_function.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
#ifndef Py_INTERNAL_FUNCTION_H
22
#define Py_INTERNAL_FUNCTION_H
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
36

7+
#ifndef Py_BUILD_CORE
8+
# error "this header requires Py_BUILD_CORE define"
9+
#endif
410

5-
#include "Python.h"
6-
7-
PyFunctionObject *
8-
_PyFunction_FromConstructor(PyFrameConstructor *constr);
11+
extern PyFunctionObject* _PyFunction_FromConstructor(PyFrameConstructor *constr);
912

13+
extern uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func);
1014

15+
#ifdef __cplusplus
16+
}
17+
#endif
1118
#endif /* !Py_INTERNAL_FUNCTION_H */

Include/internal/pycore_genobject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11+
extern PyObject *_PyGen_yf(PyGenObject *);
12+
extern PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
13+
extern PyObject *_PyAsyncGenValueWrapperNew(PyObject *);
1114

1215
/* runtime lifecycle */
1316

Python/specialize.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "Python.h"
22
#include "pycore_code.h"
33
#include "pycore_dict.h"
4+
#include "pycore_function.h" // _PyFunction_GetVersionForCurrentState()
45
#include "pycore_global_strings.h" // _Py_ID()
56
#include "pycore_long.h"
67
#include "pycore_moduleobject.h"
@@ -1928,7 +1929,7 @@ void
19281929
_Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
19291930
int oparg)
19301931
{
1931-
assert(_PyOpcode_InlineCacheEntries[BINARY_OP] ==
1932+
assert(_PyOpcode_InlineCacheEntries[BINARY_OP] ==
19321933
INLINE_CACHE_ENTRIES_BINARY_OP);
19331934
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)(instr + 1);
19341935
switch (oparg) {

0 commit comments

Comments
 (0)