From 3dabc5977d0167f3d948273eabc2a70cbcafb696 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 29 Aug 2023 03:49:17 +0200 Subject: [PATCH] gh-106320: Remove private _PyType_Lookup() function Move the private function to the internal C API (pycore_object.h). --- Include/cpython/object.h | 1 - Include/internal/pycore_object.h | 3 +++ Modules/_lsprof.c | 1 + Modules/_testcapi/gc.c | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Include/cpython/object.h b/Include/cpython/object.h index 489b2eecd32991..9a81175c152889 100644 --- a/Include/cpython/object.h +++ b/Include/cpython/object.h @@ -235,7 +235,6 @@ typedef struct _heaptypeobject { } PyHeapTypeObject; PyAPI_FUNC(const char *) _PyType_Name(PyTypeObject *); -PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *); PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, PyModuleDef *); PyAPI_FUNC(PyObject *) PyType_GetDict(PyTypeObject *); diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h index c6007718bae5a4..4114407aadea3a 100644 --- a/Include/internal/pycore_object.h +++ b/Include/internal/pycore_object.h @@ -382,6 +382,9 @@ extern PyTypeObject* _PyType_CalculateMetaclass(PyTypeObject *, PyObject *); extern PyObject* _PyType_GetDocFromInternalDoc(const char *, const char *); extern PyObject* _PyType_GetTextSignatureFromInternalDoc(const char *, const char *, int); +// Export for '_lsprof' shared extension +PyAPI_DATA(PyObject*) _PyType_Lookup(PyTypeObject *, PyObject *); + extern int _PyObject_InitializeDict(PyObject *obj); int _PyObject_InitInlineValues(PyObject *obj, PyTypeObject *tp); extern int _PyObject_StoreInstanceAttribute(PyObject *obj, PyDictValues *values, diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index e7dcb6e1713212..51388b36725ff1 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -5,6 +5,7 @@ #include "Python.h" #include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_ceval.h" // _PyEval_SetProfile() +#include "pycore_object.h" // _PyType_Lookup() #include "pycore_pystate.h" // _PyThreadState_GET() #include "rotatingtree.h" diff --git a/Modules/_testcapi/gc.c b/Modules/_testcapi/gc.c index 829200ad12cd3c..848863fdd2d5b3 100644 --- a/Modules/_testcapi/gc.c +++ b/Modules/_testcapi/gc.c @@ -1,4 +1,9 @@ +#ifndef Py_BUILD_CORE_BUILTIN +# define Py_BUILD_CORE_MODULE 1 +#endif + #include "parts.h" +#include "pycore_object.h" // _PyType_Lookup() static PyObject* test_gc_control(PyObject *self, PyObject *Py_UNUSED(ignored))