From 773b803c02b25b58af0a64321fbe1c6bf45cba2b Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 24 Aug 2023 19:07:54 +0200 Subject: [PATCH] gh-106320: Remove private _PyManagedBuffer_Type (#108431) Remove private _PyManagedBuffer_Type variable. Move it to the internal C API and no longer export it. --- Include/cpython/memoryobject.h | 2 -- Include/internal/pycore_memoryobject.h | 2 ++ Objects/memoryobject.c | 1 + Objects/object.c | 4 +++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Include/cpython/memoryobject.h b/Include/cpython/memoryobject.h index 3837fa8c6ab..961161b70f2 100644 --- a/Include/cpython/memoryobject.h +++ b/Include/cpython/memoryobject.h @@ -2,8 +2,6 @@ # error "this header file must not be included directly" #endif -PyAPI_DATA(PyTypeObject) _PyManagedBuffer_Type; - /* The structs are declared here so that macros can work, but they shouldn't be considered public. Don't access their fields directly, use the macros and functions instead! */ diff --git a/Include/internal/pycore_memoryobject.h b/Include/internal/pycore_memoryobject.h index fe19e3f9611..62e204fcbf6 100644 --- a/Include/internal/pycore_memoryobject.h +++ b/Include/internal/pycore_memoryobject.h @@ -8,6 +8,8 @@ extern "C" { # error "this header requires Py_BUILD_CORE define" #endif +extern PyTypeObject _PyManagedBuffer_Type; + PyObject * _PyMemoryView_FromBufferProc(PyObject *v, int flags, getbufferproc bufferproc); diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index b0168044d9f..bcdd2ff0cea 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -12,6 +12,7 @@ #include "Python.h" #include "pycore_abstract.h" // _PyIndex_Check() +#include "pycore_memoryobject.h" // _PyManagedBuffer_Type #include "pycore_object.h" // _PyObject_GC_UNTRACK() #include "pycore_strhex.h" // _Py_strhex_with_sep() #include // offsetof() diff --git a/Objects/object.c b/Objects/object.c index 868623a9f7b..02e26110209 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -9,15 +9,17 @@ #include "pycore_dict.h" // _PyObject_MakeDictFromInstanceAttributes() #include "pycore_floatobject.h" // _PyFloat_DebugMallocStats() #include "pycore_initconfig.h" // _PyStatus_EXCEPTION() +#include "pycore_memoryobject.h" // _PyManagedBuffer_Type #include "pycore_namespace.h" // _PyNamespace_Type #include "pycore_object.h" // PyAPI_DATA() _Py_SwappedOp definition #include "pycore_pyerrors.h" // _PyErr_Occurred() #include "pycore_pymem.h" // _PyMem_IsPtrFreed() #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_symtable.h" // PySTEntry_Type -#include "pycore_typevarobject.h" // _PyTypeAlias_Type, _Py_initialize_generic #include "pycore_typeobject.h" // _PyBufferWrapper_Type +#include "pycore_typevarobject.h" // _PyTypeAlias_Type, _Py_initialize_generic #include "pycore_unionobject.h" // _PyUnion_Type + #include "interpreteridobject.h" // _PyInterpreterID_Type #ifdef Py_LIMITED_API