Skip to content

Commit 8ba4714

Browse files
authored
gh-106320: Remove private AC converter functions (#108505)
Move these private functions to the internal C API (pycore_abstract.h): * _Py_convert_optional_to_ssize_t() * _PyNumber_Index() Argument Clinic now emits #include "pycore_abstract.h" when these functions are used. The parser of the c-analyzer tool now uses a list of files which use the limited C API, rather than a list of files using the internal C API.
1 parent 6353c21 commit 8ba4714

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+88
-62
lines changed

Include/cpython/abstract.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,3 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
5353
need to be corrected for a negative index. */
5454
#define PySequence_ITEM(o, i)\
5555
( Py_TYPE(o)->tp_as_sequence->sq_item((o), (i)) )
56-
57-
/* === Mapping protocol ================================================= */
58-
59-
// Convert Python int to Py_ssize_t. Do nothing if the argument is None.
60-
// Cannot be moved to the internal C API: used by Argument Clinic.
61-
PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *);
62-
63-
// Same as PyNumber_Index but can return an instance of a subclass of int.
64-
// Cannot be moved to the internal C API: used by Argument Clinic.
65-
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
@@ -47,6 +47,13 @@ extern int _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
4747

4848
extern int _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
4949

50+
// Convert Python int to Py_ssize_t. Do nothing if the argument is None.
51+
// Export for '_bisect' shared extension.
52+
PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *);
53+
54+
// Same as PyNumber_Index() but can return an instance of a subclass of int.
55+
// Export for 'math' shared extension.
56+
PyAPI_FUNC(PyObject*) _PyNumber_Index(PyObject *o);
5057

5158
#ifdef __cplusplus
5259
}

Modules/_io/_iomodule.c

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

1010
#include "Python.h"
11+
#include "pycore_abstract.h" // _PyNumber_Index()
1112
#include "pycore_initconfig.h" // _PyStatus_OK()
1213
#include "pycore_pystate.h" // _PyInterpreterState_GET()
1314

Modules/_io/clinic/bufferedio.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/bytesio.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/fileio.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/iobase.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/stringio.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/textio.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/winconsoleio.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)