Skip to content

Commit 8ba4714

Browse files
authored
pythongh-106320: Remove private AC converter functions (python#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

-10
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

+7
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

+1
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

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/bytesio.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/fileio.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/iobase.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/stringio.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/textio.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/winconsoleio.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_sre/clinic/sre.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_bisectmodule.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_bz2module.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_collectionsmodule.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_elementtree.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_hashopenssl.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_lzmamodule.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_operator.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_ssl.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_struct.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_testclinic.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_testclinic_depr.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/arraymodule.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/gcmodule.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/itertoolsmodule.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/posixmodule.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/zlibmodule.c.h

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/mathmodule.c

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ raised for division by zero and mod by zero.
5757
#endif
5858

5959
#include "Python.h"
60+
#include "pycore_abstract.h" // _PyNumber_Index()
6061
#include "pycore_bitutils.h" // _Py_bit_length()
6162
#include "pycore_call.h" // _PyObject_CallNoArgs()
6263
#include "pycore_long.h" // _PyLong_GetZero()

Modules/mmapmodule.c

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#endif
2424

2525
#include <Python.h>
26+
#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
2627
#include "pycore_bytesobject.h" // _PyBytes_Find()
2728
#include "pycore_fileutils.h" // _Py_stat_struct
2829

Modules/posixmodule.c

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#ifdef __VXWORKS__
1313
# include "pycore_bitutils.h" // _Py_popcount32()
1414
#endif
15+
#include "pycore_abstract.h" // _PyNumber_Index()
1516
#include "pycore_call.h" // _PyObject_CallNoArgs()
1617
#include "pycore_ceval.h" // _PyEval_ReInitThreads()
1718
#include "pycore_fileutils.h" // _Py_closerange()

0 commit comments

Comments
 (0)