]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106320: Remove private AC converter functions (#108505)
authorVictor Stinner <vstinner@python.org>
Sat, 26 Aug 2023 02:05:17 +0000 (04:05 +0200)
committerGitHub <noreply@github.com>
Sat, 26 Aug 2023 02:05:17 +0000 (04:05 +0200)
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.

41 files changed:
Include/cpython/abstract.h
Include/internal/pycore_abstract.h
Modules/_io/_iomodule.c
Modules/_io/clinic/bufferedio.c.h
Modules/_io/clinic/bytesio.c.h
Modules/_io/clinic/fileio.c.h
Modules/_io/clinic/iobase.c.h
Modules/_io/clinic/stringio.c.h
Modules/_io/clinic/textio.c.h
Modules/_io/clinic/winconsoleio.c.h
Modules/_sre/clinic/sre.c.h
Modules/clinic/_bisectmodule.c.h
Modules/clinic/_bz2module.c.h
Modules/clinic/_collectionsmodule.c.h
Modules/clinic/_elementtree.c.h
Modules/clinic/_hashopenssl.c.h
Modules/clinic/_lzmamodule.c.h
Modules/clinic/_operator.c.h
Modules/clinic/_ssl.c.h
Modules/clinic/_struct.c.h
Modules/clinic/_testclinic.c.h
Modules/clinic/_testclinic_depr.c.h
Modules/clinic/arraymodule.c.h
Modules/clinic/gcmodule.c.h
Modules/clinic/itertoolsmodule.c.h
Modules/clinic/posixmodule.c.h
Modules/clinic/zlibmodule.c.h
Modules/mathmodule.c
Modules/mmapmodule.c
Modules/posixmodule.c
Objects/clinic/bytearrayobject.c.h
Objects/clinic/bytesobject.c.h
Objects/clinic/listobject.c.h
Objects/clinic/longobject.c.h
Objects/clinic/unicodeobject.c.h
Objects/floatobject.c
Objects/stringlib/clinic/transmogrify.h.h
Python/clinic/_warnings.c.h
Python/getargs.c
Tools/c-analyzer/c_parser/preprocessor/gcc.py
Tools/clinic/clinic.py

index dd924dfd3d8fcc81ed01992378f1bf7ad9fd20f7..1f495f19df280b128b067293c348f361ecec6d11 100644 (file)
@@ -53,13 +53,3 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
    need to be corrected for a negative index. */
 #define PySequence_ITEM(o, i)\
     ( Py_TYPE(o)->tp_as_sequence->sq_item((o), (i)) )
-
-/* === Mapping protocol ================================================= */
-
-// 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.
-// Cannot be moved to the internal C API: used by Argument Clinic.
-PyAPI_FUNC(PyObject *) _PyNumber_Index(PyObject *o);
index 2733d8102e5ef4d9df4004bdb19b8e3cd21289f6..3cc0afac4bd5b45490d3edd8e92062bec837da8a 100644 (file)
@@ -47,6 +47,13 @@ extern int _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
 
 extern int _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
 
+// Convert Python int to Py_ssize_t. Do nothing if the argument is None.
+// Export for '_bisect' shared extension.
+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.
+// Export for 'math' shared extension.
+PyAPI_FUNC(PyObject*) _PyNumber_Index(PyObject *o);
 
 #ifdef __cplusplus
 }
index f56654227f1020b2d3f61226c1cdebc0eaa8a452..0762e26a36c795cf228516060868da7f3ca8309f 100644 (file)
@@ -8,6 +8,7 @@
 */
 
 #include "Python.h"
+#include "pycore_abstract.h"      // _PyNumber_Index()
 #include "pycore_initconfig.h"    // _PyStatus_OK()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
 
index b9b42cf34285738566db7878f82b0cd3325d3c19..32c4a4e177cbbeca673abc2b5553ec9ed33bac7f 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(_io__BufferedIOBase_readinto__doc__,
 "readinto($self, buffer, /)\n"
@@ -1098,4 +1099,4 @@ skip_optional_pos:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=e5b335441452653d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=768c3a3a3deabcb4 input=a9049054013a1b77]*/
index 52c9c2c5ecbb6e14d05bb579bc6e9a3142717946..b5cdd0802b87489edcb0af33e1bd4e223960847e 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _Py_convert_optional_to_ssize_t()
 
 PyDoc_STRVAR(_io_BytesIO_readable__doc__,
 "readable($self, /)\n"
@@ -538,4 +539,4 @@ skip_optional_pos:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=8d4e7651002e14c6 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6b1219bda0619e2a input=a9049054013a1b77]*/
index 9f5198d45ab819f8546635d8fa28d67cb270f4df..7b63e36b5038db165f84bde86db7498d4f17a4c9 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _Py_convert_optional_to_ssize_t()
 
 PyDoc_STRVAR(_io_FileIO_close__doc__,
 "close($self, /)\n"
@@ -536,4 +537,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored))
 #ifndef _IO_FILEIO_TRUNCATE_METHODDEF
     #define _IO_FILEIO_TRUNCATE_METHODDEF
 #endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */
-/*[clinic end generated code: output=65b9a5cc96d193b6 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=3a3c6ed7e5e78063 input=a9049054013a1b77]*/
index a539125a2a8fce4a013e59783c3e0378f06633f1..f582b9d2c7104235a90da379ab0493b4fb6b4ac4 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _Py_convert_optional_to_ssize_t()
 
 PyDoc_STRVAR(_io__IOBase_seek__doc__,
 "seek($self, offset, whence=os.SEEK_SET, /)\n"
@@ -436,4 +437,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
 {
     return _io__RawIOBase_readall_impl(self);
 }
-/*[clinic end generated code: output=0f064cfd54e3c1a5 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ec741e0961671a86 input=a9049054013a1b77]*/
index d0acfdb4bf3818fdd3e23f5e6fea0811f35780e3..dbe1833a90ed8cdbb58043ead2414d0849159119 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _Py_convert_optional_to_ssize_t()
 
 PyDoc_STRVAR(_io_StringIO_getvalue__doc__,
 "getvalue($self, /)\n"
@@ -367,4 +368,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
 {
     return _io_StringIO_seekable_impl(self);
 }
-/*[clinic end generated code: output=6f55dc1454aeb507 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=09d4056cc8c4aae4 input=a9049054013a1b77]*/
index d653cc87ae317a00df505ed65e5b6efdfcd3c079..03d5facedfb513dafae0336c5e049650d22f5223 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _Py_convert_optional_to_ssize_t()
 
 PyDoc_STRVAR(_io__TextIOBase_detach__doc__,
 "detach($self, /)\n"
@@ -975,4 +976,4 @@ _io_TextIOWrapper_close(textio *self, PyObject *Py_UNUSED(ignored))
 {
     return _io_TextIOWrapper_close_impl(self);
 }
-/*[clinic end generated code: output=29b945b24287dd0c input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c3a8eb2591be1bf7 input=a9049054013a1b77]*/
index cd3348dc1227cdd1d44bd1454980ff49c5367f4e..53f971e37c12581a1234b85a2b5271374eb0b00f 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _Py_convert_optional_to_ssize_t()
 
 #if defined(HAVE_WINDOWS_CONSOLE_IO)
 
@@ -465,4 +466,4 @@ _io__WindowsConsoleIO_isatty(winconsoleio *self, PyObject *Py_UNUSED(ignored))
 #ifndef _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
     #define _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
 #endif /* !defined(_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF) */
-/*[clinic end generated code: output=235393758365c229 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=0cdb16d95f1c7dac input=a9049054013a1b77]*/
index a303a557ca5f46a1adc8eee89bf3a36a375d2053..1846f175b4585a93f21e647be3212425d749f1a3 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(_sre_getcodesize__doc__,
 "getcodesize($module, /)\n"
@@ -1460,4 +1461,4 @@ _sre_SRE_Scanner_search(ScannerObject *self, PyTypeObject *cls, PyObject *const
     }
     return _sre_SRE_Scanner_search_impl(self, cls);
 }
-/*[clinic end generated code: output=6b84e62c87238f0e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b8cf77f05e44d08c input=a9049054013a1b77]*/
index 7944f5219b02a31a158ecd76809313f201da4c18..62ce0fc8172367279f3beb82ae651df098774efb 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(_bisect_bisect_right__doc__,
 "bisect_right($module, /, a, x, lo=0, hi=None, *, key=None)\n"
@@ -433,4 +434,4 @@ skip_optional_kwonly:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=5a7fa64bf9b262f3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=839fdddeacdc2ecb input=a9049054013a1b77]*/
index 6ad2db3ce1dee6a1d0b49c2f9e0854d11c80be31..7c4d57b5fec7e10ba3701b0783e96912045a4d4f 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(_bz2_BZ2Compressor_compress__doc__,
 "compress($self, data, /)\n"
@@ -241,4 +242,4 @@ _bz2_BZ2Decompressor(PyTypeObject *type, PyObject *args, PyObject *kwargs)
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=431fd0fc40f019d1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=40706688f92642b4 input=a9049054013a1b77]*/
index 3882d069216e28abe780abcfbe30dba599dacd99..b96502d3cf4b3f717cd67c61ab03c3a2e0e5a2cb 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(_collections__count_elements__doc__,
 "_count_elements($module, mapping, iterable, /)\n"
@@ -75,4 +76,4 @@ tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=00e516317d2b8bed input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d83188040656ad7c input=a9049054013a1b77]*/
index a0bc751ca21ee842c93a55ad9b98536a44b41a86..78e456b6a4346357a2ecc0b469dd9511f9d1e162 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(_elementtree_Element_append__doc__,
 "append($self, subelement, /)\n"
@@ -1218,4 +1219,4 @@ skip_optional:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=40767b1a98e54b60 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=0a34620406b95eb0 input=a9049054013a1b77]*/
index fb61a444018dbbbb64b1ffc50410c624c59ba695..0ea192eac2d3f177b5200b8d1e064bcaad50032f 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(EVP_copy__doc__,
 "copy($self, /)\n"
@@ -1851,4 +1852,4 @@ exit:
 #ifndef _HASHLIB_SCRYPT_METHODDEF
     #define _HASHLIB_SCRYPT_METHODDEF
 #endif /* !defined(_HASHLIB_SCRYPT_METHODDEF) */
-/*[clinic end generated code: output=b339e255db698147 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=cfad8d5e904a4917 input=a9049054013a1b77]*/
index 017b24f765eee313e355c1d117c795b19e3d65ca..ceb75399157627e56d89f0f329b86b6a6455b707 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(_lzma_LZMACompressor_compress__doc__,
 "compress($self, data, /)\n"
@@ -338,4 +339,4 @@ exit:
 
     return return_value;
 }
-/*[clinic end generated code: output=aaf225a5d15d3e75 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f1a001f5f489c372 input=a9049054013a1b77]*/
index b68e6e0144a586d312b0be7e5480f20455b89683..18b0b920b0d118692c1a4c713e0b7b0f7574f403 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(_operator_truth__doc__,
 "truth($module, a, /)\n"
@@ -1492,4 +1493,4 @@ _operator__compare_digest(PyObject *module, PyObject *const *args, Py_ssize_t na
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=227cbcfed44f736e input=a9049054013a1b77]*/
+/*[clinic end generated code: output=72bc63a775937245 input=a9049054013a1b77]*/
index 81712617bee12bd9d7a027d7ce728e8d4cf31d0f..6ab8e3ee436336f2c93fdb8ba330d77b6deb985c 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(_ssl__SSLSocket_do_handshake__doc__,
 "do_handshake($self, /)\n"
@@ -1542,4 +1543,4 @@ exit:
 #ifndef _SSL_ENUM_CRLS_METHODDEF
     #define _SSL_ENUM_CRLS_METHODDEF
 #endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
-/*[clinic end generated code: output=4c9f00c62f0825d2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6e2eb86330f3f9b8 input=a9049054013a1b77]*/
index c3cf179ed4c040d62713e48ea81458663ea5963c..a823364447818bc05b39a883f1b18e2dcc4460cb 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(Struct__doc__,
 "Struct(format)\n"
@@ -451,4 +452,4 @@ exit:
 
     return return_value;
 }
-/*[clinic end generated code: output=f3d6e06f80368998 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=9b48aeaa86898ec5 input=a9049054013a1b77]*/
index 3c04c41599c6501d49116691d537354d60036436..94c4b5a1221eeccf6b7ec33335e8a9f2c332181f 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 #include "pycore_long.h"           // _PyLong_UnsignedShort_Converter()
 
 PyDoc_STRVAR(test_empty_function__doc__,
@@ -3070,4 +3071,4 @@ skip_optional_pos:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=41f439aab0cb809d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a652e6b1787d3346 input=a9049054013a1b77]*/
index 71cb972b9513112f1be7796a9595266c6e1b6841..7b9d8971efb46beefcdcdcac2e8f213d81695d19 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 #include "pycore_long.h"           // _PyLong_UnsignedShort_Converter()
 
 PyDoc_STRVAR(depr_star_new__doc__,
@@ -2392,4 +2393,4 @@ depr_multi(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=22b59d92d517a8ec input=a9049054013a1b77]*/
+/*[clinic end generated code: output=464aeba97e482f5c input=a9049054013a1b77]*/
index 5e957013ad0dc38e1b625f45257dcc44aae280b6..8bdfcc62bef0850a3c127e8bc6d8497080ce1733 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(array_array___copy____doc__,
 "__copy__($self, /)\n"
@@ -674,4 +675,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
 
 #define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF    \
     {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
-/*[clinic end generated code: output=db417f5677a25eaa input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ab24c7a40a41c2e1 input=a9049054013a1b77]*/
index 0ea5b40cfb770a02c892844eb5232c50986b8d24..290a8aaa2728e57a29d96d1a9a720e6d32a70db4 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _Py_convert_optional_to_ssize_t()
 
 PyDoc_STRVAR(gc_enable__doc__,
 "enable($module, /)\n"
@@ -424,4 +425,4 @@ gc_get_freeze_count(PyObject *module, PyObject *Py_UNUSED(ignored))
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=16003cfbc66ada39 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=fe89ce0b90a1067d input=a9049054013a1b77]*/
index 32278bf715aa98d544b09f7d1b590a6fbdf0f823..6555bd495b200eebaf2a577b304f99d4e9a93c9b 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(batched_new__doc__,
 "batched(iterable, n)\n"
@@ -913,4 +914,4 @@ skip_optional_pos:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=111cbd102c2a23c9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=20999801c7349d2c input=a9049054013a1b77]*/
index 4b85519b532137191f8206dbf19c63bf6f6d214f..e80bbff6b5156d964f405a6d6d020b7fe403b3a0 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 #include "pycore_fileutils.h"      // _PyLong_FileDescriptor_Converter()
 #include "pycore_long.h"           // _PyLong_UnsignedInt_Converter()
 
@@ -11992,4 +11993,4 @@ exit:
 #ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF
     #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF
 #endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */
-/*[clinic end generated code: output=ff0e50316f4ed71a input=a9049054013a1b77]*/
+/*[clinic end generated code: output=1b34619e5f65adc2 input=a9049054013a1b77]*/
index 3d71536c8461092db4c1d632012ebd73a88c426c..1debe2ae98959d5cda7b64135dcd56d6398def73 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(zlib_compress__doc__,
 "compress($module, data, /, level=Z_DEFAULT_COMPRESSION, wbits=MAX_WBITS)\n"
@@ -1129,4 +1130,4 @@ exit:
 #ifndef ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
     #define ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF
 #endif /* !defined(ZLIB_DECOMPRESS___DEEPCOPY___METHODDEF) */
-/*[clinic end generated code: output=3eccb3f7265d53ba input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d574a79aa47c9969 input=a9049054013a1b77]*/
index 0d238c086ac78f62dff655b2dbdac7f0bcac868d..d929dcf65a7e32a6813fc5b82ac3ab2f7496f586 100644 (file)
@@ -57,6 +57,7 @@ raised for division by zero and mod by zero.
 #endif
 
 #include "Python.h"
+#include "pycore_abstract.h"      // _PyNumber_Index()
 #include "pycore_bitutils.h"      // _Py_bit_length()
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_long.h"          // _PyLong_GetZero()
index 5c1315701235603654870721fa907275920d84ca..44d5b268e1b74f856d17664493ddd1f804108656 100644 (file)
@@ -23,6 +23,7 @@
 #endif
 
 #include <Python.h>
+#include "pycore_abstract.h"      // _Py_convert_optional_to_ssize_t()
 #include "pycore_bytesobject.h"   // _PyBytes_Find()
 #include "pycore_fileutils.h"     // _Py_stat_struct
 
index cffa401d2ceb02fb3af52312f376f5c80628365d..8eb25fc242495c03e71b1003e43916128e4069e1 100644 (file)
@@ -12,6 +12,7 @@
 #ifdef __VXWORKS__
 #  include "pycore_bitutils.h"    // _Py_popcount32()
 #endif
+#include "pycore_abstract.h"      // _PyNumber_Index()
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_ceval.h"         // _PyEval_ReInitThreads()
 #include "pycore_fileutils.h"     // _Py_closerange()
index ecb08a86c2aab546a3c78a5bfc70cbc2d34b8c39..f091fc7afbd693b8fe6d3f3c5772db523364abe7 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 static int
 bytearray___init___impl(PyByteArrayObject *self, PyObject *arg,
@@ -1284,4 +1285,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
 {
     return bytearray_sizeof_impl(self);
 }
-/*[clinic end generated code: output=cb94d7ac45f0a4b7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d388e9027b333f00 input=a9049054013a1b77]*/
index 904ff07e97cde3ed16a50bb7c316533cb817d4f8..66db76dbbb4faf496642c9291c6311e400222dd6 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(bytes___bytes____doc__,
 "__bytes__($self, /)\n"
@@ -1060,4 +1061,4 @@ skip_optional_pos:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=f4e85363c79c64d3 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=9da56b6c04914e18 input=a9049054013a1b77]*/
index e3d6ffa9f76fdb5f84e9becfd73e0842ed82fdfa..a41ed3e4b040d9403ccfac312e9da8ff37b1a72b 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(list_insert__doc__,
 "insert($self, index, object, /)\n"
@@ -383,4 +384,4 @@ list___reversed__(PyListObject *self, PyObject *Py_UNUSED(ignored))
 {
     return list___reversed___impl(self);
 }
-/*[clinic end generated code: output=2ca109d8acc775bc input=a9049054013a1b77]*/
+/*[clinic end generated code: output=537a17b562c57505 input=a9049054013a1b77]*/
index d37e44f2f330bd1b3f48972070d8df899652a049..3ecef1f0fd54d491cbb3e9b9a7704b1d9c3efe72 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 static PyObject *
 long_new_impl(PyTypeObject *type, PyObject *x, PyObject *obase);
@@ -475,4 +476,4 @@ int_is_integer(PyObject *self, PyObject *Py_UNUSED(ignored))
 {
     return int_is_integer_impl(self);
 }
-/*[clinic end generated code: output=75ed306fff493ba1 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=ea9c87ea532dadbe input=a9049054013a1b77]*/
index 7edb4bc76099bee642a1bb3124b99e8e70c8ea9b..56b64087d6654afc16ebdc73e2426ded69a02aeb 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(EncodingMap_size__doc__,
 "size($self, /)\n"
@@ -1504,4 +1505,4 @@ skip_optional_pos:
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=2e1e1b136ef1b681 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a64776a3ea1c970c input=a9049054013a1b77]*/
index 6a0c2e033e3e9a06ae2aebb12aef906c5ea5e6e8..1c5078bdda687194925272f179aa12d6158f1f89 100644 (file)
@@ -4,6 +4,7 @@
    for any kind of float exception without losing portability. */
 
 #include "Python.h"
+#include "pycore_abstract.h"      // _PyNumber_Index()
 #include "pycore_dtoa.h"          // _Py_dg_dtoa()
 #include "pycore_floatobject.h"   // _PyFloat_FormatAdvancedWriter()
 #include "pycore_initconfig.h"    // _PyStatus_OK()
index 1e0df0958d6a4d5d72a001534a68d742872e04b3..d1adda4e979c1499b2aaf7b26e4533cebd513390 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(stringlib_expandtabs__doc__,
 "expandtabs($self, /, tabsize=8)\n"
@@ -278,4 +279,4 @@ stringlib_zfill(PyObject *self, PyObject *arg)
 exit:
     return return_value;
 }
-/*[clinic end generated code: output=00e34c03331699fe input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a0338b2d41671b17 input=a9049054013a1b77]*/
index b39e412a7d6de95fb788756e7ee6c9658abfbbd0..1a01416e7363c7aa430aa6a1e8612b2e0c8a604e 100644 (file)
@@ -7,6 +7,7 @@ preserve
 #  include "pycore_runtime.h"       // _Py_ID()
 #endif
 
+#include "pycore_abstract.h"       // _PyNumber_Index()
 
 PyDoc_STRVAR(warnings_warn__doc__,
 "warn($module, /, message, category=None, stacklevel=1, source=None, *,\n"
@@ -243,4 +244,4 @@ warnings_filters_mutated(PyObject *module, PyObject *Py_UNUSED(ignored))
 {
     return warnings_filters_mutated_impl(module);
 }
-/*[clinic end generated code: output=0e2b367a662bf51b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=c8a6dc1403fba1d5 input=a9049054013a1b77]*/
index 809b2d4ef17d3da4d823d7bba290e2d8f7eea5be..fdc144488c9627cabfd4a26cb9dabb48f17e3467 100644 (file)
@@ -2,6 +2,7 @@
 /* New getargs implementation */
 
 #include "Python.h"
+#include "pycore_abstract.h"      // _PyNumber_Index()
 #include "pycore_dict.h"          // _PyDict_HasOnlyStringKeys()
 #include "pycore_pylifecycle.h"   // _PyArg_Fini
 #include "pycore_tuple.h"         // _PyTuple_ITEMS()
index de9a2484de82bbb72c6f40ae45f74d707a5f35c4..55cc2d37e1ebc7c5c69fcbc224c5943d99f154d0 100644 (file)
@@ -3,26 +3,14 @@ import re
 
 from . import common as _common
 
-# Modules/socketmodule.h uses pycore_time.h which needs the Py_BUILD_CORE
-# macro. Usually it's defined by the C file which includes it.
-# Other header files have a similar issue.
-NEED_BUILD_CORE = {
-    # Header ".h" files
-    'cjkcodecs.h',
-    'multibytecodec.h',
-    'socketmodule.h',
-
-    # Argument Clinic ".c.h" header files
-    '_testclinic.c.h',
-    '_testclinic_depr.c.h',
-    '_winapi.c.h',
-    'fcntlmodule.c.h',
-    'overlapped.c.h',
-    'posixmodule.c.h',
-    'selectmodule.c.h',
-    'sha3module.c.h',
-    'termios.c.h',
-}
+# The following C files must not be built with Py_BUILD_CORE,
+# because they use the limited C API.
+USE_LIMITED_C_API = frozenset((
+    '_testcapimodule.c',
+    '_testclinic_limited.c',
+    'xxlimited.c',
+    'xxlimited_35.c',
+))
 
 TOOL = 'gcc'
 
@@ -81,8 +69,9 @@ def preprocess(filename,
         cwd = os.path.abspath(cwd or '.')
     filename = _normpath(filename, cwd)
 
+    print(filename)
     postargs = POST_ARGS
-    if os.path.basename(filename) in NEED_BUILD_CORE:
+    if os.path.basename(filename) not in USE_LIMITED_C_API:
         postargs += ('-DPy_BUILD_CORE=1',)
 
     text = _common.preprocess(
index e622d254ee8ccbfc1790f628fc3724a0c357ca1f..70ec18f726e3f4f76996840ea30b917e917e62c4 100755 (executable)
@@ -3795,8 +3795,11 @@ class Py_ssize_t_converter(CConverter):
         if accept == {int}:
             self.format_unit = 'n'
             self.default_type = int
+            self.add_include('pycore_abstract.h', '_PyNumber_Index()')
         elif accept == {int, NoneType}:
             self.converter = '_Py_convert_optional_to_ssize_t'
+            self.add_include('pycore_abstract.h',
+                             '_Py_convert_optional_to_ssize_t()')
         else:
             fail(f"Py_ssize_t_converter: illegal 'accept' argument {accept!r}")