]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106084: Remove _PyObject_RealIsInstance() function (#106106)
authorVictor Stinner <vstinner@python.org>
Mon, 26 Jun 2023 13:38:41 +0000 (15:38 +0200)
committerGitHub <noreply@github.com>
Mon, 26 Jun 2023 13:38:41 +0000 (13:38 +0000)
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.

Include/cpython/abstract.h
Include/internal/pycore_abstract.h
Objects/abstract.c
Objects/descrobject.c
Objects/exceptions.c

index cba0f4c31309213a1bc36ec5b2c13ff2da19cdcc..5eb22ff61ecddcde455149d409f7df4dd4c987a7 100644 (file)
@@ -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);
index 9ba27487f5bbf1bbd5ea1aaaa9e75afb52fa884b..2733d8102e5ef4d9df4004bdb19b8e3cd21289f6 100644 (file)
@@ -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
index fecdb4e07239a263df01c4cf3884ed5325913177..80a40944d6d219680704829e82471ad031c437d2 100644 (file)
@@ -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;
index 98d8698fa70fbca66c5015390145893d99723e14..89bac99bb9d6380fe69f4256cb220f9624399f77 100644 (file)
@@ -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()
index f27e6f6c1431a01cb8df01c855577311e0e0d190..015dd27ec33308541ad1f3662616988de0cd2902 100644 (file)
@@ -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