From 33ed5fa69dbe25d64a910c450be527f4db9dc5dd Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Wed, 1 Nov 2023 08:44:54 +0300 Subject: [PATCH] gh-111495: add stub files for C API test modules (GH-111586) This is to reduce merge conflicts (Modules/Setup.stdlib.in) for subsequent pull requests for the issue. --- Modules/Setup.stdlib.in | 2 +- Modules/_testcapi/bytearray.c | 17 +++++++++++++++++ Modules/_testcapi/bytes.c | 17 +++++++++++++++++ Modules/_testcapi/codec.c | 17 +++++++++++++++++ Modules/_testcapi/complex.c | 16 ++++++++++++++++ Modules/_testcapi/file.c | 17 +++++++++++++++++ Modules/_testcapi/list.c | 17 +++++++++++++++++ Modules/_testcapi/numbers.c | 16 ++++++++++++++++ Modules/_testcapi/parts.h | 12 ++++++++++-- Modules/_testcapi/tuple.c | 17 +++++++++++++++++ Modules/_testcapimodule.c | 24 ++++++++++++++++++++++++ PCbuild/_testcapi.vcxproj | 8 ++++++++ PCbuild/_testcapi.vcxproj.filters | 27 +++++++++++++++++++++++++++ 13 files changed, 204 insertions(+), 3 deletions(-) create mode 100644 Modules/_testcapi/bytearray.c create mode 100644 Modules/_testcapi/bytes.c create mode 100644 Modules/_testcapi/codec.c create mode 100644 Modules/_testcapi/complex.c create mode 100644 Modules/_testcapi/file.c create mode 100644 Modules/_testcapi/list.c create mode 100644 Modules/_testcapi/numbers.c create mode 100644 Modules/_testcapi/tuple.c diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index c73522b8ecf..9e1188304de 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -159,7 +159,7 @@ @MODULE__XXTESTFUZZ_TRUE@_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c @MODULE__TESTBUFFER_TRUE@_testbuffer _testbuffer.c @MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c _testinternalcapi/test_lock.c _testinternalcapi/pytime.c _testinternalcapi/set.c -@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c _testcapi/vectorcall_limited.c _testcapi/heaptype.c _testcapi/abstract.c _testcapi/unicode.c _testcapi/dict.c _testcapi/set.c _testcapi/getargs.c _testcapi/datetime.c _testcapi/docstring.c _testcapi/mem.c _testcapi/watchers.c _testcapi/long.c _testcapi/float.c _testcapi/structmember.c _testcapi/exceptions.c _testcapi/code.c _testcapi/buffer.c _testcapi/pyatomic.c _testcapi/pyos.c _testcapi/immortal.c _testcapi/heaptype_relative.c _testcapi/gc.c _testcapi/sys.c +@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c _testcapi/vectorcall_limited.c _testcapi/heaptype.c _testcapi/abstract.c _testcapi/bytearray.c _testcapi/bytes.c _testcapi/unicode.c _testcapi/dict.c _testcapi/set.c _testcapi/list.c _testcapi/tuple.c _testcapi/getargs.c _testcapi/datetime.c _testcapi/docstring.c _testcapi/mem.c _testcapi/watchers.c _testcapi/long.c _testcapi/float.c _testcapi/complex.c _testcapi/numbers.c _testcapi/structmember.c _testcapi/exceptions.c _testcapi/code.c _testcapi/buffer.c _testcapi/pyatomic.c _testcapi/pyos.c _testcapi/file.c _testcapi/codec.c _testcapi/immortal.c _testcapi/heaptype_relative.c _testcapi/gc.c _testcapi/sys.c @MODULE__TESTCLINIC_TRUE@_testclinic _testclinic.c @MODULE__TESTCLINIC_LIMITED_TRUE@_testclinic_limited _testclinic_limited.c diff --git a/Modules/_testcapi/bytearray.c b/Modules/_testcapi/bytearray.c new file mode 100644 index 00000000000..6ddb8fe1d5f --- /dev/null +++ b/Modules/_testcapi/bytearray.c @@ -0,0 +1,17 @@ +#include "parts.h" +#include "util.h" + + +static PyMethodDef test_methods[] = { + {NULL}, +}; + +int +_PyTestCapi_Init_ByteArray(PyObject *m) +{ + if (PyModule_AddFunctions(m, test_methods) < 0) { + return -1; + } + + return 0; +} diff --git a/Modules/_testcapi/bytes.c b/Modules/_testcapi/bytes.c new file mode 100644 index 00000000000..9fea716bfbc --- /dev/null +++ b/Modules/_testcapi/bytes.c @@ -0,0 +1,17 @@ +#include "parts.h" +#include "util.h" + + +static PyMethodDef test_methods[] = { + {NULL}, +}; + +int +_PyTestCapi_Init_Bytes(PyObject *m) +{ + if (PyModule_AddFunctions(m, test_methods) < 0) { + return -1; + } + + return 0; +} diff --git a/Modules/_testcapi/codec.c b/Modules/_testcapi/codec.c new file mode 100644 index 00000000000..d13f51e2033 --- /dev/null +++ b/Modules/_testcapi/codec.c @@ -0,0 +1,17 @@ +#include "parts.h" +#include "util.h" + + +static PyMethodDef test_methods[] = { + {NULL}, +}; + +int +_PyTestCapi_Init_Codec(PyObject *m) +{ + if (PyModule_AddFunctions(m, test_methods) < 0){ + return -1; + } + + return 0; +} diff --git a/Modules/_testcapi/complex.c b/Modules/_testcapi/complex.c new file mode 100644 index 00000000000..0402b8ecc95 --- /dev/null +++ b/Modules/_testcapi/complex.c @@ -0,0 +1,16 @@ +#include "parts.h" +#include "util.h" + +static PyMethodDef test_methods[] = { + {NULL}, +}; + +int +_PyTestCapi_Init_Complex(PyObject *mod) +{ + if (PyModule_AddFunctions(mod, test_methods) < 0) { + return -1; + } + + return 0; +} diff --git a/Modules/_testcapi/file.c b/Modules/_testcapi/file.c new file mode 100644 index 00000000000..634563f6ea1 --- /dev/null +++ b/Modules/_testcapi/file.c @@ -0,0 +1,17 @@ +#include "parts.h" +#include "util.h" + + +static PyMethodDef test_methods[] = { + {NULL}, +}; + +int +_PyTestCapi_Init_File(PyObject *m) +{ + if (PyModule_AddFunctions(m, test_methods) < 0){ + return -1; + } + + return 0; +} diff --git a/Modules/_testcapi/list.c b/Modules/_testcapi/list.c new file mode 100644 index 00000000000..9329ddc3bdd --- /dev/null +++ b/Modules/_testcapi/list.c @@ -0,0 +1,17 @@ +#include "parts.h" +#include "util.h" + + +static PyMethodDef test_methods[] = { + {NULL}, +}; + +int +_PyTestCapi_Init_List(PyObject *m) +{ + if (PyModule_AddFunctions(m, test_methods) < 0){ + return -1; + } + + return 0; +} diff --git a/Modules/_testcapi/numbers.c b/Modules/_testcapi/numbers.c new file mode 100644 index 00000000000..6f7fa3fa7a4 --- /dev/null +++ b/Modules/_testcapi/numbers.c @@ -0,0 +1,16 @@ +#include "parts.h" +#include "util.h" + +static PyMethodDef test_methods[] = { + {NULL}, +}; + +int +_PyTestCapi_Init_Numbers(PyObject *mod) +{ + if (PyModule_AddFunctions(mod, test_methods) < 0) { + return -1; + } + + return 0; +} diff --git a/Modules/_testcapi/parts.h b/Modules/_testcapi/parts.h index 4fa77a8844e..9af414e10d0 100644 --- a/Modules/_testcapi/parts.h +++ b/Modules/_testcapi/parts.h @@ -31,6 +31,8 @@ int _PyTestCapi_Init_Vectorcall(PyObject *module); int _PyTestCapi_Init_Heaptype(PyObject *module); int _PyTestCapi_Init_Abstract(PyObject *module); +int _PyTestCapi_Init_ByteArray(PyObject *module); +int _PyTestCapi_Init_Bytes(PyObject *module); int _PyTestCapi_Init_Unicode(PyObject *module); int _PyTestCapi_Init_GetArgs(PyObject *module); int _PyTestCapi_Init_DateTime(PyObject *module); @@ -39,17 +41,23 @@ int _PyTestCapi_Init_Mem(PyObject *module); int _PyTestCapi_Init_Watchers(PyObject *module); int _PyTestCapi_Init_Long(PyObject *module); int _PyTestCapi_Init_Float(PyObject *module); +int _PyTestCapi_Init_Complex(PyObject *module); +int _PyTestCapi_Init_Numbers(PyObject *module); int _PyTestCapi_Init_Dict(PyObject *module); int _PyTestCapi_Init_Set(PyObject *module); +int _PyTestCapi_Init_List(PyObject *module); +int _PyTestCapi_Init_Tuple(PyObject *module); int _PyTestCapi_Init_Structmember(PyObject *module); int _PyTestCapi_Init_Exceptions(PyObject *module); int _PyTestCapi_Init_Code(PyObject *module); int _PyTestCapi_Init_Buffer(PyObject *module); int _PyTestCapi_Init_PyAtomic(PyObject *module); int _PyTestCapi_Init_PyOS(PyObject *module); +int _PyTestCapi_Init_File(PyObject *module); +int _PyTestCapi_Init_Codec(PyObject *module); int _PyTestCapi_Init_Immortal(PyObject *module); -int _PyTestCapi_Init_GC(PyObject *mod); -int _PyTestCapi_Init_Sys(PyObject *); +int _PyTestCapi_Init_GC(PyObject *module); +int _PyTestCapi_Init_Sys(PyObject *module); int _PyTestCapi_Init_VectorcallLimited(PyObject *module); int _PyTestCapi_Init_HeaptypeRelative(PyObject *module); diff --git a/Modules/_testcapi/tuple.c b/Modules/_testcapi/tuple.c new file mode 100644 index 00000000000..95dde8c0eda --- /dev/null +++ b/Modules/_testcapi/tuple.c @@ -0,0 +1,17 @@ +#include "parts.h" +#include "util.h" + + +static PyMethodDef test_methods[] = { + {NULL}, +}; + +int +_PyTestCapi_Init_Tuple(PyObject *m) +{ + if (PyModule_AddFunctions(m, test_methods) < 0){ + return -1; + } + + return 0; +} diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index fc9dc746095..300025ce370 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -3908,6 +3908,12 @@ PyInit__testcapi(void) if (_PyTestCapi_Init_Abstract(m) < 0) { return NULL; } + if (_PyTestCapi_Init_ByteArray(m) < 0) { + return NULL; + } + if (_PyTestCapi_Init_Bytes(m) < 0) { + return NULL; + } if (_PyTestCapi_Init_Unicode(m) < 0) { return NULL; } @@ -3932,12 +3938,24 @@ PyInit__testcapi(void) if (_PyTestCapi_Init_Float(m) < 0) { return NULL; } + if (_PyTestCapi_Init_Complex(m) < 0) { + return NULL; + } + if (_PyTestCapi_Init_Numbers(m) < 0) { + return NULL; + } if (_PyTestCapi_Init_Dict(m) < 0) { return NULL; } if (_PyTestCapi_Init_Set(m) < 0) { return NULL; } + if (_PyTestCapi_Init_List(m) < 0) { + return NULL; + } + if (_PyTestCapi_Init_Tuple(m) < 0) { + return NULL; + } if (_PyTestCapi_Init_Structmember(m) < 0) { return NULL; } @@ -3953,6 +3971,12 @@ PyInit__testcapi(void) if (_PyTestCapi_Init_PyOS(m) < 0) { return NULL; } + if (_PyTestCapi_Init_File(m) < 0) { + return NULL; + } + if (_PyTestCapi_Init_Codec(m) < 0) { + return NULL; + } if (_PyTestCapi_Init_Sys(m) < 0) { return NULL; } diff --git a/PCbuild/_testcapi.vcxproj b/PCbuild/_testcapi.vcxproj index ae97c34eed5..2d8a652a84b 100644 --- a/PCbuild/_testcapi.vcxproj +++ b/PCbuild/_testcapi.vcxproj @@ -100,21 +100,29 @@ + + + + + + + + diff --git a/PCbuild/_testcapi.vcxproj.filters b/PCbuild/_testcapi.vcxproj.filters index c3ad2564edd..573e54d56a2 100644 --- a/PCbuild/_testcapi.vcxproj.filters +++ b/PCbuild/_testcapi.vcxproj.filters @@ -30,12 +30,27 @@ Source Files + + Source Files + + + Source Files + Source Files Source Files + + Source Files + + + Source Files + + + Source Files + Source Files @@ -54,6 +69,12 @@ Source Files + + Source Files + + + Source Files + Source Files @@ -72,6 +93,12 @@ Source Files + + Source Files + + + Source Files + Source Files