Skip to content

bpo-45316: Move private functions to internal C API #31579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Include/cpython/frameobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ PyAPI_DATA(PyTypeObject) PyFrame_Type;
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
PyObject *, PyObject *);

/* only internal use */
PyFrameObject*
_PyFrame_New_NoTrack(PyCodeObject *code);


/* The rest of the interface is specific for frame objects */

/* Conversions between "fast locals" and locals in dictionary */
Expand Down
2 changes: 0 additions & 2 deletions Include/cpython/funcobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ PyAPI_FUNC(PyObject *) _PyFunction_Vectorcall(
size_t nargsf,
PyObject *kwnames);

uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func);

/* Macros for direct access to these values. Type checks are *not*
done, so use with care. */
#define PyFunction_GET_CODE(func) \
Expand Down
4 changes: 0 additions & 4 deletions Include/cpython/genobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(PyFrameObject *,
PyObject *name, PyObject *qualname);
PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
PyObject *_PyGen_yf(PyGenObject *);
PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);


Expand All @@ -59,7 +58,6 @@ PyAPI_DATA(PyTypeObject) PyCoro_Type;
PyAPI_DATA(PyTypeObject) _PyCoroWrapper_Type;

#define PyCoro_CheckExact(op) Py_IS_TYPE(op, &PyCoro_Type)
PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *,
PyObject *name, PyObject *qualname);

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

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

PyObject *_PyAsyncGenValueWrapperNew(PyObject *);


#undef _PyGenObject_HEAD

Expand Down
2 changes: 2 additions & 0 deletions Include/internal/pycore_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct _frame {
PyObject *_f_frame_data[1];
};

extern PyFrameObject* _PyFrame_New_NoTrack(PyCodeObject *code);

/* runtime lifecycle */

extern void _PyFrame_Fini(PyInterpreterState *interp);
Expand Down
15 changes: 11 additions & 4 deletions Include/internal/pycore_function.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#ifndef Py_INTERNAL_FUNCTION_H
#define Py_INTERNAL_FUNCTION_H
#ifdef __cplusplus
extern "C" {
#endif

#ifndef Py_BUILD_CORE
# error "this header requires Py_BUILD_CORE define"
#endif

#include "Python.h"

PyFunctionObject *
_PyFunction_FromConstructor(PyFrameConstructor *constr);
extern PyFunctionObject* _PyFunction_FromConstructor(PyFrameConstructor *constr);

extern uint32_t _PyFunction_GetVersionForCurrentState(PyFunctionObject *func);

#ifdef __cplusplus
}
#endif
#endif /* !Py_INTERNAL_FUNCTION_H */
3 changes: 3 additions & 0 deletions Include/internal/pycore_genobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif

extern PyObject *_PyGen_yf(PyGenObject *);
extern PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
extern PyObject *_PyAsyncGenValueWrapperNew(PyObject *);

/* runtime lifecycle */

Expand Down
3 changes: 2 additions & 1 deletion Python/specialize.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Python.h"
#include "pycore_code.h"
#include "pycore_dict.h"
#include "pycore_function.h" // _PyFunction_GetVersionForCurrentState()
#include "pycore_global_strings.h" // _Py_ID()
#include "pycore_long.h"
#include "pycore_moduleobject.h"
Expand Down Expand Up @@ -1928,7 +1929,7 @@ void
_Py_Specialize_BinaryOp(PyObject *lhs, PyObject *rhs, _Py_CODEUNIT *instr,
int oparg)
{
assert(_PyOpcode_InlineCacheEntries[BINARY_OP] ==
assert(_PyOpcode_InlineCacheEntries[BINARY_OP] ==
INLINE_CACHE_ENTRIES_BINARY_OP);
_PyBinaryOpCache *cache = (_PyBinaryOpCache *)(instr + 1);
switch (oparg) {
Expand Down