8000 gh-106084: Remove _PyObject_RealIsInstance() function (#106106) · python/cpython@e8e59ee · GitHub
[go: up one dir, main page]

Skip to content

Commit e8e59ee

Browse files
authored
gh-106084: Remove _PyObject_RealIsInstance() function (#106106)
Remove the following functions from the public C API: * _PyObject_RealIsInstance() * _PyObject_RealIsSubclass() * _Py_add_one_to_index_F() * _Py_add_one_to_index_C() Move _PyObject_RealIsInstance() and _PyObject_RealIsSubclass() to the internal C API (pycore_abstract.h) and no longer export their symbols (in libpython). Make _Py_add_one_to_index_F() and _Py_add_one_to_index_C() functions static: no longer export them.
1 parent 6200aaf commit e8e59ee

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

Include/cpython/abstract.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,10 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
147147

148148
/* === Mapping protocol ================================================= */
149149

150-
PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
151-
152-
PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
153-
154-
/* For internal use by buffer API functions */
155-
PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index,
156-
const Py_ssize_t *shape);
157-
PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
158-
const Py_ssize_t *shape);
159-
160-
/* Convert Python int to Py_ssize_t. Do nothing if the argument is None. */
150+
// Convert Python int to Py_ssize_t. Do nothing if the argument is None.
151+
// Cannot be moved to the internal C API: used by Argument Clinic.
161152
PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *);
162153

163-
/* Same as PyNumber_Index but can return an instance of a subclass of int. */
154+
// Same as PyNumber_Index but can return an instance of a subclass of int.
155+
// Cannot be moved to the internal C API: used by Argument Clinic.
164156
PyAPI_FUNC(PyObject *) _PyNumber_Index(PyObject *o);

Include/internal/pycore_abstract.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ extern int _PyObject_HasLen(PyObject *o);
4141
extern Py_ssize_t _PySequence_IterSearch(PyObject *seq,
4242
PyObject *obj, int operation);
4343

44+
/* === Mapping protocol ================================================= */
45+
46+
extern int _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
47+
48+
extern int _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
49+
50+
4451
#ifdef __cplusplus
4552
}
4653
#endif

Objects/abstract.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ PyBuffer_GetPointer(const Py_buffer *view, const Py_ssize_t *indices)
517517
}
518518

519519

520-
void
520+
static void
521521
_Py_add_one_to_index_F(int nd, Py_ssize_t *index, const Py_ssize_t *shape)
522522
{
523523
int k;
@@ -533,7 +533,7 @@ _Py_add_one_to_index_F(int nd, Py_ssize_t *index, const Py_ssize_t *shape)
533533
}
534534
}
535535

536-
void
536+
static void
537537
_Py_add_one_to_index_C(int nd, Py_ssize_t *index, const Py_ssize_t *shape)
538538
{
539539
int k;

Objects/descrobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* Descriptors -- a new, flexible way to describe attributes */
22

33
#include "Python.h"
4+
#include "pycore_abstract.h" // _PyObject_RealIsSubclass()
45
#include "pycore_ceval.h" // _Py_EnterRecursiveCallTstate()
56
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
67
#include "pycore_pystate.h" // _PyThreadState_GET()

Objects/exceptions.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define PY_SSIZE_T_CLEAN
88
#include <Python.h>
99
#include <stdbool.h>
10+
#include "pycore_abstract.h" // _PyObject_RealIsSubclass()
1011
#include "pycore_ceval.h" // _Py_EnterRecursiveCall
1112
#include "pycore_pyerrors.h" // struct _PyErr_SetRaisedException
1213
#include "pycore_exceptions.h" // struct _Py_exc_state

0 commit comments

Comments
 (0)
0