diff options
author | Victor Stinner <vstinner@python.org> | 2023-06-26 13:38:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-26 13:38:41 (GMT) |
commit | e8e59ee474869e7c02e7cae3815c9c2183671b21 (patch) | |
tree | eea724df61695783e1e08876449292815dfc30b3 | |
parent | 6200aaf2967de420a2d83236008787c9f791561d (diff) | |
download | cpython-e8e59ee474869e7c02e7cae3815c9c2183671b21.zip cpython-e8e59ee474869e7c02e7cae3815c9c2183671b21.tar.gz cpython-e8e59ee474869e7c02e7cae3815c9c2183671b21.tar.bz2 |
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.
-rw-r--r-- | Include/cpython/abstract.h | 16 | ||||
-rw-r--r-- | Include/internal/pycore_abstract.h | 7 | ||||
-rw-r--r-- | Objects/abstract.c | 4 | ||||
-rw-r--r-- | Objects/descrobject.c | 1 | ||||
-rw-r--r-- | Objects/exceptions.c | 1 |
5 files changed, 15 insertions, 14 deletions
diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h index cba0f4c..5eb22ff 100644 --- a/Include/cpython/abstract.h +++ b/Include/cpython/abstract.h @@ -147,18 +147,10 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t); /* === Mapping protocol ================================================= */ -PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls); - -PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls); - -/* For internal use by buffer API functions */ -PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index, - const Py_ssize_t *shape); -PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index, - const Py_ssize_t *shape); - -/* Convert Python int to Py_ssize_t. Do nothing if the argument is None. */ +// Convert Python int to Py_ssize_t. Do nothing if the argument is None. +// Cannot be moved to the internal C API: used by Argument Clinic. PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *); -/* Same as PyNumber_Index but can return an instance of a subclass of int. */ +// Same as PyNumber_Index but can return an instance of a subclass of int. +// Cannot be moved to the internal C API: used by Argument Clinic. PyAPI_FUNC(PyObject *) _PyNumber_Index(PyObject *o); diff --git a/Include/internal/pycore_abstract.h b/Include/internal/pycore_abstract.h index 9ba2748..2733d81 100644 --- a/Include/internal/pycore_abstract.h +++ b/Include/internal/pycore_abstract.h @@ -41,6 +41,13 @@ extern int _PyObject_HasLen(PyObject *o); extern Py_ssize_t _PySequence_IterSearch(PyObject *seq, PyObject *obj, int operation); +/* === Mapping protocol ================================================= */ + +extern int _PyObject_RealIsInstance(PyObject *inst, PyObject *cls); + +extern int _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls); + + #ifdef __cplusplus } #endif diff --git a/Objects/abstract.c b/Objects/abstract.c index fecdb4e..80a4094 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -517,7 +517,7 @@ PyBuffer_GetPointer(const Py_buffer *view, const Py_ssize_t *indices) } -void +static void _Py_add_one_to_index_F(int nd, Py_ssize_t *index, const Py_ssize_t *shape) { int k; @@ -533,7 +533,7 @@ _Py_add_one_to_index_F(int nd, Py_ssize_t *index, const Py_ssize_t *shape) } } -void +static void _Py_add_one_to_index_C(int nd, Py_ssize_t *index, const Py_ssize_t *shape) { int k; diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 98d8698..89bac99 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1,6 +1,7 @@ /* Descriptors -- a new, flexible way to describe attributes */ #include "Python.h" +#include "pycore_abstract.h" // _PyObject_RealIsSubclass() #include "pycore_ceval.h" // _Py_EnterRecursiveCallTstate() #include "pycore_object.h" // _PyObject_GC_UNTRACK() #include "pycore_pystate.h" // _PyThreadState_GET() diff --git a/Objects/exceptions.c b/Objects/exceptions.c index f27e6f6..015dd27 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -7,6 +7,7 @@ #define PY_SSIZE_T_CLEAN #include <Python.h> #include <stdbool.h> +#include "pycore_abstract.h" // _PyObject_RealIsSubclass() #include "pycore_ceval.h" // _Py_EnterRecursiveCall #include "pycore_pyerrors.h" // struct _PyErr_SetRaisedException #include "pycore_exceptions.h" // struct _Py_exc_state |