gh-138342: Move _PyObject_VisitType() to the internal C API (#139734)

This commit is contained in:
Victor Stinner
2025-10-08 12:10:58 +02:00
committed by GitHub
parent a15aeec29e
commit c4e7d245d6
15 changed files with 35 additions and 11 deletions

View File

@@ -492,7 +492,3 @@ PyAPI_FUNC(int) PyUnstable_TryIncRef(PyObject *);
PyAPI_FUNC(void) PyUnstable_EnableTryIncRef(PyObject *);
PyAPI_FUNC(int) PyUnstable_Object_IsUniquelyReferenced(PyObject *);
/* Utility for the tp_traverse slot of mutable heap types that have no other
* references. */
PyAPI_FUNC(int) _PyObject_VisitType(PyObject *op, visitproc visit, void *arg);

View File

@@ -1047,6 +1047,10 @@ static inline Py_ALWAYS_INLINE void _Py_INCREF_MORTAL(PyObject *op)
}
#endif
/* Utility for the tp_traverse slot of mutable heap types that have no other
* references. */
PyAPI_FUNC(int) _PyObject_VisitType(PyObject *op, visitproc visit, void *arg);
#ifdef __cplusplus
}
#endif

View File

@@ -8,6 +8,7 @@
#endif
#include "Python.h"
#include "pycore_object.h" // _PyObject_VisitType()
#include <sys/types.h>
#include <sys/stat.h>

View File

@@ -30,9 +30,9 @@
#endif
#include <Python.h>
#include "pycore_object.h" // _PyObject_VisitType()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_typeobject.h"
#include "complexobject.h"
#include <mpdecimal.h>

View File

@@ -8,11 +8,12 @@
#endif
#include "Python.h"
#include "pycore_pyerrors.h" // _PyErr_SetLocaleString()
#include "pycore_object.h" // _PyObject_VisitType()
#include "pycore_pyerrors.h" // _PyErr_SetLocaleString()
#include "gdbm.h"
#include <fcntl.h>
#include <stdlib.h> // free()
#include <stdlib.h> // free()
#include <sys/stat.h>
#include <sys/types.h>

View File

@@ -8,6 +8,7 @@
*/
#include "multiprocessing.h"
#include "pycore_object.h" // _PyObject_VisitType()
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h> // gettimeofday()

View File

@@ -21,8 +21,15 @@
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif
#include "prepare_protocol.h"
#include "pycore_object.h" // _PyObject_VisitType()
static int
pysqlite_prepare_protocol_init(PyObject *self, PyObject *args, PyObject *kwargs)
{

View File

@@ -21,10 +21,17 @@
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif
#include "connection.h"
#include "statement.h"
#include "util.h"
#include "pycore_object.h" // _PyObject_VisitType()
#define _pysqlite_Statement_CAST(op) ((pysqlite_Statement *)(op))
/* prototypes */

View File

@@ -16,9 +16,10 @@
#include "Python.h"
#include "hashlib.h"
#include "pycore_strhex.h" // _Py_strhex()
#include "pycore_typeobject.h"
#include "pycore_moduleobject.h"
#include "pycore_object.h" // _PyObject_VisitType()
#include "pycore_strhex.h" // _Py_strhex()
#include "pycore_typeobject.h"
// QUICK CPU AUTODETECTION
//

View File

@@ -22,7 +22,8 @@
#endif
#include "Python.h"
#include "pycore_strhex.h" // _Py_strhex()
#include "pycore_object.h" // _PyObject_VisitType()
#include "pycore_strhex.h" // _Py_strhex()
#include "hashlib.h"

View File

@@ -21,6 +21,7 @@
#include "Python.h"
#include "hashlib.h"
#include "pycore_object.h" // _PyObject_VisitType()
#include "pycore_strhex.h" // _Py_strhex()
#include "pycore_typeobject.h" // _PyType_GetModuleState()

View File

@@ -22,8 +22,9 @@
#include "Python.h"
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "pycore_typeobject.h" // _PyType_GetModuleState()
#include "pycore_object.h" // _PyObject_VisitType()
#include "pycore_strhex.h" // _Py_strhex()
#include "pycore_typeobject.h" // _PyType_GetModuleState()
#include "hashlib.h"

View File

@@ -21,6 +21,7 @@
#endif
#include "Python.h"
#include "pycore_object.h" // _PyObject_VisitType()
#include "pycore_strhex.h" // _Py_strhex()
#include "pycore_typeobject.h" // _PyType_GetModuleState()
#include "hashlib.h"

View File

@@ -109,6 +109,7 @@ Local naming conventions:
#include "pycore_capsule.h" // _PyCapsule_SetTraverse()
#include "pycore_fileutils.h" // _Py_set_inheritable()
#include "pycore_moduleobject.h" // _PyModule_GetState
#include "pycore_object.h" // _PyObject_VisitType()
#include "pycore_time.h" // _PyTime_AsMilliseconds()
#include "pycore_pystate.h" // _Py_AssertHoldsTstate()

View File

@@ -17,6 +17,7 @@
#endif
#include "Python.h"
#include "pycore_object.h" // _PyObject_VisitType()
#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
#include <stdbool.h>