]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45316: Move private functions to internal C API (GH-31579)
authorVictor Stinner <vstinner@python.org>
Fri, 25 Feb 2022 15:07:14 +0000 (16:07 +0100)
committerGitHub <noreply@github.com>
Fri, 25 Feb 2022 15:07:14 +0000 (16:07 +0100)
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()

Include/cpython/frameobject.h
Include/cpython/funcobject.h
Include/cpython/genobject.h
Include/internal/pycore_frame.h
Include/internal/pycore_function.h
Include/internal/pycore_genobject.h
Python/specialize.c

index e69209686bee02697fd54534d0074474ea861621..ebaecbed1b487b1c1159f8c272b6b24bca12e91d 100644 (file)
@@ -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 */
index 9f0560fb725036d79a33c7fba693f83f1db1868d..99ac6008f8b611f83724f18097702e0661455aa5 100644 (file)
@@ -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) \
index 838ca6cd24691492879928b366a68022aecf3919..b485ac6183e2ee3ec5659d1d8082133e4fa4bd61 100644 (file)
@@ -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);
 
 
@@ -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);
 
@@ -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
 
index 09d41222b61fc9de7c6f67ea4782773ba33aca28..f8b8e001025af3f78896b98539d5467739c849bf 100644 (file)
@@ -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);
index dc4422df3eb5312b593e1c115e9ef7a97d241b7d..1c87aa31ddb611e82faf8b2fd0e5708298c1e940 100644 (file)
@@ -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 */
index 74a676df4ad534537ca94cb38d71c66626693fe1..42db0d87d1f40a0abe4d965473fabf9354f332a0 100644 (file)
@@ -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 */
 
index e1db12b853c7c08f70899a26a7157ab17241198a..1624f1955d42a7c059f7313af5e926de0864cbfd 100644 (file)
@@ -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"
@@ -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) {