Skip to content

Commit c4e7d24

Browse files
authored
gh-138342: Move _PyObject_VisitType() to the internal C API (#139734)
1 parent a15aeec commit c4e7d24

File tree

15 files changed

+35
-11
lines changed

15 files changed

+35
-11
lines changed

Include/cpython/object.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,3 @@ PyAPI_FUNC(int) PyUnstable_TryIncRef(PyObject *);
492492
PyAPI_FUNC(void) PyUnstable_EnableTryIncRef(PyObject *);
493493

494494
PyAPI_FUNC(int) PyUnstable_Object_IsUniquelyReferenced(PyObject *);
495-
496-
/* Utility for the tp_traverse slot of mutable heap types that have no other
497-
* references. */
498-
PyAPI_FUNC(int) _PyObject_VisitType(PyObject *op, visitproc visit, void *arg);

Include/internal/pycore_object.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,10 @@ static inline Py_ALWAYS_INLINE void _Py_INCREF_MORTAL(PyObject *op)
10471047
}
10481048
#endif
10491049

1050+
/* Utility for the tp_traverse slot of mutable heap types that have no other
1051+
* references. */
1052+
PyAPI_FUNC(int) _PyObject_VisitType(PyObject *op, visitproc visit, void *arg);
1053+
10501054
#ifdef __cplusplus
10511055
}
10521056
#endif

Modules/_dbmmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#endif
99

1010
#include "Python.h"
11+
#include "pycore_object.h" // _PyObject_VisitType()
1112

1213
#include <sys/types.h>
1314
#include <sys/stat.h>

Modules/_decimal/_decimal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
#endif
3131

3232
#include <Python.h>
33+
#include "pycore_object.h" // _PyObject_VisitType()
3334
#include "pycore_pystate.h" // _PyThreadState_GET()
3435
#include "pycore_typeobject.h"
35-
#include "complexobject.h"
3636

3737
#include <mpdecimal.h>
3838

Modules/_gdbmmodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
#endif
99

1010
#include "Python.h"
11-
#include "pycore_pyerrors.h" // _PyErr_SetLocaleString()
11+
#include "pycore_object.h" // _PyObject_VisitType()
12+
#include "pycore_pyerrors.h" // _PyErr_SetLocaleString()
1213
#include "gdbm.h"
1314

1415
#include <fcntl.h>
15-
#include <stdlib.h> // free()
16+
#include <stdlib.h> // free()
1617
#include <sys/stat.h>
1718
#include <sys/types.h>
1819

Modules/_multiprocessing/semaphore.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include "multiprocessing.h"
11+
#include "pycore_object.h" // _PyObject_VisitType()
1112

1213
#ifdef HAVE_SYS_TIME_H
1314
# include <sys/time.h> // gettimeofday()

Modules/_sqlite/prepare_protocol.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@
2121
* 3. This notice may not be removed or altered from any source distribution.
2222
*/
2323

24+
#ifndef Py_BUILD_CORE_BUILTIN
25+
# define Py_BUILD_CORE_MODULE 1
26+
#endif
27+
2428
#include "prepare_protocol.h"
2529

30+
#include "pycore_object.h" // _PyObject_VisitType()
31+
32+
2633
static int
2734
pysqlite_prepare_protocol_init(PyObject *self, PyObject *args, PyObject *kwargs)
2835
{

Modules/_sqlite/statement.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@
2121
* 3. This notice may not be removed or altered from any source distribution.
2222
*/
2323

24+
#ifndef Py_BUILD_CORE_BUILTIN
25+
# define Py_BUILD_CORE_MODULE 1
26+
#endif
27+
2428
#include "connection.h"
2529
#include "statement.h"
2630
#include "util.h"
2731

32+
#include "pycore_object.h" // _PyObject_VisitType()
33+
34+
2835
#define _pysqlite_Statement_CAST(op) ((pysqlite_Statement *)(op))
2936

3037
/* prototypes */

Modules/blake2module.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
#include "Python.h"
1818
#include "hashlib.h"
19-
#include "pycore_strhex.h" // _Py_strhex()
20-
#include "pycore_typeobject.h"
2119
#include "pycore_moduleobject.h"
20+
#include "pycore_object.h" // _PyObject_VisitType()
21+
#include "pycore_strhex.h" // _Py_strhex()
22+
#include "pycore_typeobject.h"
2223

2324
// QUICK CPU AUTODETECTION
2425
//

Modules/md5module.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
#endif
2323

2424
#include "Python.h"
25-
#include "pycore_strhex.h" // _Py_strhex()
25+
#include "pycore_object.h" // _PyObject_VisitType()
26+
#include "pycore_strhex.h" // _Py_strhex()
2627

2728
#include "hashlib.h"
2829

0 commit comments

Comments
 (0)