From 9020fe313416c69fc13982692e36ab2b8288faaf Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Mon, 4 Jul 2022 18:27:31 +0200 Subject: [PATCH 1/5] gh-93649: Split vectorcall testing from _testcapimodule.c The _testcapimodule.c file is getting too large to work with effectively. Vectorcall tests aren't the biggest issue -- it's just an area I want to work on next, so I started there. It does make it clear that MethodDescriptor2 is related to testing vectorcall, which wasn't clear before (the /* Test PEP 590 */ section had an ambiguous end). This PR lays out a general structure of how tests can be split up, with more splitting to come later if the structure is OK. --- Modules/Setup.stdlib.in | 2 +- Modules/_testcapi/README.txt | 3 + Modules/_testcapi/test_vectorcall.c | 270 +++++++++++++++++++++++ Modules/_testcapi/testcapimodule_parts.h | 3 + Modules/_testcapimodule.c | 259 +--------------------- PCbuild/_testcapi.vcxproj | 3 +- PCbuild/_testcapi.vcxproj.filters | 5 +- setup.py | 2 +- 8 files changed, 293 insertions(+), 254 deletions(-) create mode 100644 Modules/_testcapi/README.txt create mode 100644 Modules/_testcapi/test_vectorcall.c create mode 100644 Modules/_testcapi/testcapimodule_parts.h diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index ad34f85e254514..6a0562e08cef52 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -168,7 +168,7 @@ @MODULE__XXTESTFUZZ_TRUE@_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c @MODULE__TESTBUFFER_TRUE@_testbuffer _testbuffer.c @MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c -@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c +@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/test_vectorcall.c # Some testing modules MUST be built as shared libraries. *shared* diff --git a/Modules/_testcapi/README.txt b/Modules/_testcapi/README.txt new file mode 100644 index 00000000000000..134b6efc638095 --- /dev/null +++ b/Modules/_testcapi/README.txt @@ -0,0 +1,3 @@ +Tests in this directory are compiled into the _testcapi extension. +The main file for the extension is Modules/_testcapimodule.c, which +calls `_PyTestCapi_Init_*` from these functions. diff --git a/Modules/_testcapi/test_vectorcall.c b/Modules/_testcapi/test_vectorcall.c new file mode 100644 index 00000000000000..c27ba88717ad92 --- /dev/null +++ b/Modules/_testcapi/test_vectorcall.c @@ -0,0 +1,270 @@ +#include "testcapimodule_parts.h" +#include // offsetof + + +/* Test PEP 590 - Vectorcall */ + +static int +fastcall_args(PyObject *args, PyObject ***stack, Py_ssize_t *nargs) +{ + if (args == Py_None) { + *stack = NULL; + *nargs = 0; + } + else if (PyTuple_Check(args)) { + *stack = ((PyTupleObject *)args)->ob_item; + *nargs = PyTuple_GET_SIZE(args); + } + else { + PyErr_SetString(PyExc_TypeError, "args must be None or a tuple"); + return -1; + } + return 0; +} + + +static PyObject * +test_pyobject_fastcall(PyObject *self, PyObject *args) +{ + PyObject *func, *func_args; + PyObject **stack; + Py_ssize_t nargs; + + if (!PyArg_ParseTuple(args, "OO", &func, &func_args)) { + return NULL; + } + + if (fastcall_args(func_args, &stack, &nargs) < 0) { + return NULL; + } + return _PyObject_FastCall(func, stack, nargs); +} + +static PyObject * +test_pyobject_fastcalldict(PyObject *self, PyObject *args) +{ + PyObject *func, *func_args, *kwargs; + PyObject **stack; + Py_ssize_t nargs; + + if (!PyArg_ParseTuple(args, "OOO", &func, &func_args, &kwargs)) { + return NULL; + } + + if (fastcall_args(func_args, &stack, &nargs) < 0) { + return NULL; + } + + if (kwargs == Py_None) { + kwargs = NULL; + } + else if (!PyDict_Check(kwargs)) { + PyErr_SetString(PyExc_TypeError, "kwnames must be None or a dict"); + return NULL; + } + + return PyObject_VectorcallDict(func, stack, nargs, kwargs); +} + +static PyObject * +test_pyobject_vectorcall(PyObject *self, PyObject *args) +{ + PyObject *func, *func_args, *kwnames = NULL; + PyObject **stack; + Py_ssize_t nargs, nkw; + + if (!PyArg_ParseTuple(args, "OOO", &func, &func_args, &kwnames)) { + return NULL; + } + + if (fastcall_args(func_args, &stack, &nargs) < 0) { + return NULL; + } + + if (kwnames == Py_None) { + kwnames = NULL; + } + else if (PyTuple_Check(kwnames)) { + nkw = PyTuple_GET_SIZE(kwnames); + if (nargs < nkw) { + PyErr_SetString(PyExc_ValueError, "kwnames longer than args"); + return NULL; + } + nargs -= nkw; + } + else { + PyErr_SetString(PyExc_TypeError, "kwnames must be None or a tuple"); + return NULL; + } + return PyObject_Vectorcall(func, stack, nargs, kwnames); +} + +static PyObject * +test_pyvectorcall_call(PyObject *self, PyObject *args) +{ + PyObject *func; + PyObject *argstuple; + PyObject *kwargs = NULL; + + if (!PyArg_ParseTuple(args, "OO|O", &func, &argstuple, &kwargs)) { + return NULL; + } + + if (!PyTuple_Check(argstuple)) { + PyErr_SetString(PyExc_TypeError, "args must be a tuple"); + return NULL; + } + if (kwargs != NULL && !PyDict_Check(kwargs)) { + PyErr_SetString(PyExc_TypeError, "kwargs must be a dict"); + return NULL; + } + + return PyVectorcall_Call(func, argstuple, kwargs); +} + +static PyMethodDef TestMethods[] = { + {"pyobject_fastcall", test_pyobject_fastcall, METH_VARARGS}, + {"pyobject_fastcalldict", test_pyobject_fastcalldict, METH_VARARGS}, + {"pyobject_vectorcall", test_pyobject_vectorcall, METH_VARARGS}, + {"pyvectorcall_call", test_pyvectorcall_call, METH_VARARGS}, + {NULL}, +}; + + +typedef struct { + PyObject_HEAD + vectorcallfunc vectorcall; +} MethodDescriptorObject; + +static PyObject * +MethodDescriptor_vectorcall(PyObject *callable, PyObject *const *args, + size_t nargsf, PyObject *kwnames) +{ + /* True if using the vectorcall function in MethodDescriptorObject + * but False for MethodDescriptor2Object */ + MethodDescriptorObject *md = (MethodDescriptorObject *)callable; + return PyBool_FromLong(md->vectorcall != NULL); +} + +static PyObject * +MethodDescriptor_new(PyTypeObject* type, PyObject* args, PyObject *kw) +{ + MethodDescriptorObject *op = (MethodDescriptorObject *)type->tp_alloc(type, 0); + op->vectorcall = MethodDescriptor_vectorcall; + return (PyObject *)op; +} + +static PyObject * +func_descr_get(PyObject *func, PyObject *obj, PyObject *type) +{ + if (obj == Py_None || obj == NULL) { + Py_INCREF(func); + return func; + } + return PyMethod_New(func, obj); +} + +static PyObject * +nop_descr_get(PyObject *func, PyObject *obj, PyObject *type) +{ + Py_INCREF(func); + return func; +} + +static PyObject * +call_return_args(PyObject *self, PyObject *args, PyObject *kwargs) +{ + Py_INCREF(args); + return args; +} + +static PyTypeObject MethodDescriptorBase_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "MethodDescriptorBase", + sizeof(MethodDescriptorObject), + .tp_new = MethodDescriptor_new, + .tp_call = PyVectorcall_Call, + .tp_vectorcall_offset = offsetof(MethodDescriptorObject, vectorcall), + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_METHOD_DESCRIPTOR | Py_TPFLAGS_HAVE_VECTORCALL, + .tp_descr_get = func_descr_get, +}; + +static PyTypeObject MethodDescriptorDerived_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "MethodDescriptorDerived", + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, +}; + +static PyTypeObject MethodDescriptorNopGet_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "MethodDescriptorNopGet", + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + .tp_call = call_return_args, + .tp_descr_get = nop_descr_get, +}; + +typedef struct { + MethodDescriptorObject base; + vectorcallfunc vectorcall; +} MethodDescriptor2Object; + +static PyObject * +MethodDescriptor2_new(PyTypeObject* type, PyObject* args, PyObject *kw) +{ + MethodDescriptor2Object *op = PyObject_New(MethodDescriptor2Object, type); + op->base.vectorcall = NULL; + op->vectorcall = MethodDescriptor_vectorcall; + return (PyObject *)op; +} + +static PyTypeObject MethodDescriptor2_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "MethodDescriptor2", + sizeof(MethodDescriptor2Object), + .tp_new = MethodDescriptor2_new, + .tp_call = PyVectorcall_Call, + .tp_vectorcall_offset = offsetof(MethodDescriptor2Object, vectorcall), + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_VECTORCALL, +}; + + +int +_PyTestCapi_Init_Vectorcall(PyObject *m) { + if (PyModule_AddFunctions(m, TestMethods) < 0) { + return -1; + } + + if (PyType_Ready(&MethodDescriptorBase_Type) < 0) { + return -1; + } + if (PyModule_AddType(m, &MethodDescriptorBase_Type) < 0) { + return -1; + } + + MethodDescriptorDerived_Type.tp_base = &MethodDescriptorBase_Type; + if (PyType_Ready(&MethodDescriptorDerived_Type) < 0) { + return -1; + } + if (PyModule_AddType(m, &MethodDescriptorDerived_Type) < 0) { + return -1; + } + + MethodDescriptorNopGet_Type.tp_base = &MethodDescriptorBase_Type; + if (PyType_Ready(&MethodDescriptorNopGet_Type) < 0) { + return -1; + } + if (PyModule_AddType(m, &MethodDescriptorNopGet_Type) < 0) { + return -1; + } + + MethodDescriptor2_Type.tp_base = &MethodDescriptorBase_Type; + if (PyType_Ready(&MethodDescriptor2_Type) < 0) { + return -1; + } + if (PyModule_AddType(m, &MethodDescriptor2_Type) < 0) { + return -1; + } + + return 0; +} diff --git a/Modules/_testcapi/testcapimodule_parts.h b/Modules/_testcapi/testcapimodule_parts.h new file mode 100644 index 00000000000000..1111021e1852b3 --- /dev/null +++ b/Modules/_testcapi/testcapimodule_parts.h @@ -0,0 +1,3 @@ +#include "Python.h" + +PyAPI_FUNC(int) _PyTestCapi_Init_Vectorcall(PyObject *module); diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 7d88f4f51f8313..fd15fa2975541a 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -43,6 +43,10 @@ # error "The public headers should not include , see bpo-46748" #endif +// Several parts of this module are broken out into files in _testcapi/. +// Include definitions from there. +#include "_testcapi/testcapimodule_parts.h" + // Forward declarations static struct PyModuleDef _testcapimodule; static PyType_Spec HeapTypeNameType_Spec; @@ -5299,128 +5303,6 @@ raise_SIGINT_then_send_None(PyObject *self, PyObject *args) } -static int -fastcall_args(PyObject *args, PyObject ***stack, Py_ssize_t *nargs) -{ - if (args == Py_None) { - *stack = NULL; - *nargs = 0; - } - else if (PyTuple_Check(args)) { - *stack = ((PyTupleObject *)args)->ob_item; - *nargs = PyTuple_GET_SIZE(args); - } - else { - PyErr_SetString(PyExc_TypeError, "args must be None or a tuple"); - return -1; - } - return 0; -} - - -static PyObject * -test_pyobject_fastcall(PyObject *self, PyObject *args) -{ - PyObject *func, *func_args; - PyObject **stack; - Py_ssize_t nargs; - - if (!PyArg_ParseTuple(args, "OO", &func, &func_args)) { - return NULL; - } - - if (fastcall_args(func_args, &stack, &nargs) < 0) { - return NULL; - } - return _PyObject_FastCall(func, stack, nargs); -} - - -static PyObject * -test_pyobject_fastcalldict(PyObject *self, PyObject *args) -{ - PyObject *func, *func_args, *kwargs; - PyObject **stack; - Py_ssize_t nargs; - - if (!PyArg_ParseTuple(args, "OOO", &func, &func_args, &kwargs)) { - return NULL; - } - - if (fastcall_args(func_args, &stack, &nargs) < 0) { - return NULL; - } - - if (kwargs == Py_None) { - kwargs = NULL; - } - else if (!PyDict_Check(kwargs)) { - PyErr_SetString(PyExc_TypeError, "kwnames must be None or a dict"); - return NULL; - } - - return PyObject_VectorcallDict(func, stack, nargs, kwargs); -} - - -static PyObject * -test_pyobject_vectorcall(PyObject *self, PyObject *args) -{ - PyObject *func, *func_args, *kwnames = NULL; - PyObject **stack; - Py_ssize_t nargs, nkw; - - if (!PyArg_ParseTuple(args, "OOO", &func, &func_args, &kwnames)) { - return NULL; - } - - if (fastcall_args(func_args, &stack, &nargs) < 0) { - return NULL; - } - - if (kwnames == Py_None) { - kwnames = NULL; - } - else if (PyTuple_Check(kwnames)) { - nkw = PyTuple_GET_SIZE(kwnames); - if (nargs < nkw) { - PyErr_SetString(PyExc_ValueError, "kwnames longer than args"); - return NULL; - } - nargs -= nkw; - } - else { - PyErr_SetString(PyExc_TypeError, "kwnames must be None or a tuple"); - return NULL; - } - return PyObject_Vectorcall(func, stack, nargs, kwnames); -} - - -static PyObject * -test_pyvectorcall_call(PyObject *self, PyObject *args) -{ - PyObject *func; - PyObject *argstuple; - PyObject *kwargs = NULL; - - if (!PyArg_ParseTuple(args, "OO|O", &func, &argstuple, &kwargs)) { - return NULL; - } - - if (!PyTuple_Check(argstuple)) { - PyErr_SetString(PyExc_TypeError, "args must be a tuple"); - return NULL; - } - if (kwargs != NULL && !PyDict_Check(kwargs)) { - PyErr_SetString(PyExc_TypeError, "kwargs must be a dict"); - return NULL; - } - - return PyVectorcall_Call(func, argstuple, kwargs); -} - - static PyObject* stack_pointer(PyObject *self, PyObject *args) { @@ -6403,10 +6285,6 @@ static PyMethodDef TestMethods[] = { {"tracemalloc_get_traceback", tracemalloc_get_traceback, METH_VARARGS}, {"dict_get_version", dict_get_version, METH_VARARGS}, {"raise_SIGINT_then_send_None", raise_SIGINT_then_send_None, METH_VARARGS}, - {"pyobject_fastcall", test_pyobject_fastcall, METH_VARARGS}, - {"pyobject_fastcalldict", test_pyobject_fastcalldict, METH_VARARGS}, - {"pyobject_vectorcall", test_pyobject_vectorcall, METH_VARARGS}, - {"pyvectorcall_call", test_pyvectorcall_call, METH_VARARGS}, {"stack_pointer", stack_pointer, METH_NOARGS}, #ifdef W_STOPCODE {"W_STOPCODE", py_w_stopcode, METH_VARARGS}, @@ -7009,106 +6887,6 @@ static PyTypeObject Generic_Type = { .tp_methods = generic_methods, }; - -/* Test PEP 590 */ - -typedef struct { - PyObject_HEAD - vectorcallfunc vectorcall; -} MethodDescriptorObject; - -static PyObject * -MethodDescriptor_vectorcall(PyObject *callable, PyObject *const *args, - size_t nargsf, PyObject *kwnames) -{ - /* True if using the vectorcall function in MethodDescriptorObject - * but False for MethodDescriptor2Object */ - MethodDescriptorObject *md = (MethodDescriptorObject *)callable; - return PyBool_FromLong(md->vectorcall != NULL); -} - -static PyObject * -MethodDescriptor_new(PyTypeObject* type, PyObject* args, PyObject *kw) -{ - MethodDescriptorObject *op = (MethodDescriptorObject *)type->tp_alloc(type, 0); - op->vectorcall = MethodDescriptor_vectorcall; - return (PyObject *)op; -} - -static PyObject * -func_descr_get(PyObject *func, PyObject *obj, PyObject *type) -{ - if (obj == Py_None || obj == NULL) { - Py_INCREF(func); - return func; - } - return PyMethod_New(func, obj); -} - -static PyObject * -nop_descr_get(PyObject *func, PyObject *obj, PyObject *type) -{ - Py_INCREF(func); - return func; -} - -static PyObject * -call_return_args(PyObject *self, PyObject *args, PyObject *kwargs) -{ - Py_INCREF(args); - return args; -} - -static PyTypeObject MethodDescriptorBase_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "MethodDescriptorBase", - sizeof(MethodDescriptorObject), - .tp_new = MethodDescriptor_new, - .tp_call = PyVectorcall_Call, - .tp_vectorcall_offset = offsetof(MethodDescriptorObject, vectorcall), - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_METHOD_DESCRIPTOR | Py_TPFLAGS_HAVE_VECTORCALL, - .tp_descr_get = func_descr_get, -}; - -static PyTypeObject MethodDescriptorDerived_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "MethodDescriptorDerived", - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, -}; - -static PyTypeObject MethodDescriptorNopGet_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "MethodDescriptorNopGet", - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .tp_call = call_return_args, - .tp_descr_get = nop_descr_get, -}; - -typedef struct { - MethodDescriptorObject base; - vectorcallfunc vectorcall; -} MethodDescriptor2Object; - -static PyObject * -MethodDescriptor2_new(PyTypeObject* type, PyObject* args, PyObject *kw) -{ - MethodDescriptor2Object *op = PyObject_New(MethodDescriptor2Object, type); - op->base.vectorcall = NULL; - op->vectorcall = MethodDescriptor_vectorcall; - return (PyObject *)op; -} - -static PyTypeObject MethodDescriptor2_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "MethodDescriptor2", - sizeof(MethodDescriptor2Object), - .tp_new = MethodDescriptor2_new, - .tp_call = PyVectorcall_Call, - .tp_vectorcall_offset = offsetof(MethodDescriptor2Object, vectorcall), - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_VECTORCALL, -}; - PyDoc_STRVAR(heapdocctype__doc__, "HeapDocCType(arg1, arg2)\n" "--\n" @@ -7778,29 +7556,6 @@ PyInit__testcapi(void) Py_INCREF(&MyList_Type); PyModule_AddObject(m, "MyList", (PyObject *)&MyList_Type); - if (PyType_Ready(&MethodDescriptorBase_Type) < 0) - return NULL; - Py_INCREF(&MethodDescriptorBase_Type); - PyModule_AddObject(m, "MethodDescriptorBase", (PyObject *)&MethodDescriptorBase_Type); - - MethodDescriptorDerived_Type.tp_base = &MethodDescriptorBase_Type; - if (PyType_Ready(&MethodDescriptorDerived_Type) < 0) - return NULL; - Py_INCREF(&MethodDescriptorDerived_Type); - PyModule_AddObject(m, "MethodDescriptorDerived", (PyObject *)&MethodDescriptorDerived_Type); - - MethodDescriptorNopGet_Type.tp_base = &MethodDescriptorBase_Type; - if (PyType_Ready(&MethodDescriptorNopGet_Type) < 0) - return NULL; - Py_INCREF(&MethodDescriptorNopGet_Type); - PyModule_AddObject(m, "MethodDescriptorNopGet", (PyObject *)&MethodDescriptorNopGet_Type); - - MethodDescriptor2_Type.tp_base = &MethodDescriptorBase_Type; - if (PyType_Ready(&MethodDescriptor2_Type) < 0) - return NULL; - Py_INCREF(&MethodDescriptor2_Type); - PyModule_AddObject(m, "MethodDescriptor2", (PyObject *)&MethodDescriptor2_Type); - if (PyType_Ready(&GenericAlias_Type) < 0) return NULL; Py_INCREF(&GenericAlias_Type); @@ -7973,6 +7728,11 @@ PyInit__testcapi(void) (PyObject *) &ContainerNoGC_type) < 0) return NULL; + /* Include tests from the _testcapi/ directory */ + if(_PyTestCapi_Init_Vectorcall(m) < 0) { + return NULL; + } + PyState_AddModule(m, &_testcapimodule); return m; } @@ -8024,7 +7784,6 @@ test_buildvalue_issue38913(PyObject *self, PyObject *Py_UNUSED(ignored)) } PyErr_Clear(); - Py_RETURN_NONE; } diff --git a/PCbuild/_testcapi.vcxproj b/PCbuild/_testcapi.vcxproj index c1a19437253b7e..a3383765f41816 100644 --- a/PCbuild/_testcapi.vcxproj +++ b/PCbuild/_testcapi.vcxproj @@ -94,6 +94,7 @@ + @@ -107,4 +108,4 @@ - \ No newline at end of file + diff --git a/PCbuild/_testcapi.vcxproj.filters b/PCbuild/_testcapi.vcxproj.filters index 53f64b7aa1e1a2..f106042ef5d05a 100644 --- a/PCbuild/_testcapi.vcxproj.filters +++ b/PCbuild/_testcapi.vcxproj.filters @@ -12,10 +12,13 @@ Source Files + + Source Files + Resource Files - \ No newline at end of file + diff --git a/setup.py b/setup.py index cc11dedee1b2e2..365f97d20904d0 100644 --- a/setup.py +++ b/setup.py @@ -994,7 +994,7 @@ def detect_simple_extensions(self): def detect_test_extensions(self): # Python C API test module - self.addext(Extension('_testcapi', ['_testcapimodule.c'])) + self.addext(Extension('_testcapi', ['_testcapimodule.c', '_testcapi/test_vectorcall.c'])) # Python Internal C API test module self.addext(Extension('_testinternalcapi', ['_testinternalcapi.c'])) From 735b3b52347b62479f3c624d7045bce1bfef0bc9 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 8 Jul 2022 16:17:23 +0200 Subject: [PATCH 2/5] Add testcapi parts to Makefile.pre.in --- Makefile.pre.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 14e7f6035578be..5f4d1a33922de4 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -2563,7 +2563,7 @@ MODULE__SHA3_DEPS=$(srcdir)/Modules/_sha3/sha3.c $(srcdir)/Modules/_sha3/sha3.h MODULE__SHA512_DEPS=$(srcdir)/Modules/hashlib.h MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h MODULE__SSL_DEPS=$(srcdir)/Modules/_ssl.h $(srcdir)/Modules/_ssl/cert.c $(srcdir)/Modules/_ssl/debughelpers.c $(srcdir)/Modules/_ssl/misc.c $(srcdir)/Modules/_ssl_data.h $(srcdir)/Modules/_ssl_data_111.h $(srcdir)/Modules/_ssl_data_300.h $(srcdir)/Modules/socketmodule.h -MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/testcapi_long.h +MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/testcapi_long.h Modules/_testcapi/testcapimodule_parts.h $(srcdir)/Modules/_testcapi/test_vectorcall.c MODULE__SQLITE3_DEPS=$(srcdir)/Modules/_sqlite/connection.h $(srcdir)/Modules/_sqlite/cursor.h $(srcdir)/Modules/_sqlite/microprotocols.h $(srcdir)/Modules/_sqlite/module.h $(srcdir)/Modules/_sqlite/prepare_protocol.h $(srcdir)/Modules/_sqlite/row.h $(srcdir)/Modules/_sqlite/util.h # IF YOU PUT ANYTHING HERE IT WILL GO AWAY From abeb4dc4cc399f6fd0ac45d305dc4c61d47a6a9b Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 8 Jul 2022 16:23:06 +0200 Subject: [PATCH 3/5] Remove trailing newlines in vcxproj files --- PCbuild/_testcapi.vcxproj | 2 +- PCbuild/_testcapi.vcxproj.filters | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PCbuild/_testcapi.vcxproj b/PCbuild/_testcapi.vcxproj index a3383765f41816..367f245dbd2dfa 100644 --- a/PCbuild/_testcapi.vcxproj +++ b/PCbuild/_testcapi.vcxproj @@ -108,4 +108,4 @@ - + \ No newline at end of file diff --git a/PCbuild/_testcapi.vcxproj.filters b/PCbuild/_testcapi.vcxproj.filters index f106042ef5d05a..c151abea33f50c 100644 --- a/PCbuild/_testcapi.vcxproj.filters +++ b/PCbuild/_testcapi.vcxproj.filters @@ -21,4 +21,4 @@ Resource Files - + \ No newline at end of file From 96764cae15bc7637f97eb10880701a55b4265f58 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 8 Jul 2022 16:52:12 +0200 Subject: [PATCH 4/5] Use shorter file names --- Makefile.pre.in | 2 +- Modules/Setup.stdlib.in | 2 +- Modules/_testcapi/{testcapimodule_parts.h => parts.h} | 0 Modules/_testcapi/{test_vectorcall.c => vectorcall.c} | 2 +- Modules/_testcapimodule.c | 2 +- PCbuild/_testcapi.vcxproj | 2 +- PCbuild/_testcapi.vcxproj.filters | 2 +- setup.py | 2 +- 8 files changed, 7 insertions(+), 7 deletions(-) rename Modules/_testcapi/{testcapimodule_parts.h => parts.h} (100%) rename Modules/_testcapi/{test_vectorcall.c => vectorcall.c} (99%) diff --git a/Makefile.pre.in b/Makefile.pre.in index 5f4d1a33922de4..1296c09fb48495 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -2563,7 +2563,7 @@ MODULE__SHA3_DEPS=$(srcdir)/Modules/_sha3/sha3.c $(srcdir)/Modules/_sha3/sha3.h MODULE__SHA512_DEPS=$(srcdir)/Modules/hashlib.h MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h MODULE__SSL_DEPS=$(srcdir)/Modules/_ssl.h $(srcdir)/Modules/_ssl/cert.c $(srcdir)/Modules/_ssl/debughelpers.c $(srcdir)/Modules/_ssl/misc.c $(srcdir)/Modules/_ssl_data.h $(srcdir)/Modules/_ssl_data_111.h $(srcdir)/Modules/_ssl_data_300.h $(srcdir)/Modules/socketmodule.h -MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/testcapi_long.h Modules/_testcapi/testcapimodule_parts.h $(srcdir)/Modules/_testcapi/test_vectorcall.c +MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/testcapi_long.h Modules/_testcapi/parts.h $(srcdir)/Modules/_testcapi/vectorcall.c MODULE__SQLITE3_DEPS=$(srcdir)/Modules/_sqlite/connection.h $(srcdir)/Modules/_sqlite/cursor.h $(srcdir)/Modules/_sqlite/microprotocols.h $(srcdir)/Modules/_sqlite/module.h $(srcdir)/Modules/_sqlite/prepare_protocol.h $(srcdir)/Modules/_sqlite/row.h $(srcdir)/Modules/_sqlite/util.h # IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index 6a0562e08cef52..7ff820fd43af6f 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -168,7 +168,7 @@ @MODULE__XXTESTFUZZ_TRUE@_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c @MODULE__TESTBUFFER_TRUE@_testbuffer _testbuffer.c @MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c -@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/test_vectorcall.c +@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c # Some testing modules MUST be built as shared libraries. *shared* diff --git a/Modules/_testcapi/testcapimodule_parts.h b/Modules/_testcapi/parts.h similarity index 100% rename from Modules/_testcapi/testcapimodule_parts.h rename to Modules/_testcapi/parts.h diff --git a/Modules/_testcapi/test_vectorcall.c b/Modules/_testcapi/vectorcall.c similarity index 99% rename from Modules/_testcapi/test_vectorcall.c rename to Modules/_testcapi/vectorcall.c index c27ba88717ad92..9bc702905caf76 100644 --- a/Modules/_testcapi/test_vectorcall.c +++ b/Modules/_testcapi/vectorcall.c @@ -1,4 +1,4 @@ -#include "testcapimodule_parts.h" +#include "parts.h" #include // offsetof diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index fd15fa2975541a..f4ef8492985fc0 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -45,7 +45,7 @@ // Several parts of this module are broken out into files in _testcapi/. // Include definitions from there. -#include "_testcapi/testcapimodule_parts.h" +#include "_testcapi/parts.h" // Forward declarations static struct PyModuleDef _testcapimodule; diff --git a/PCbuild/_testcapi.vcxproj b/PCbuild/_testcapi.vcxproj index 367f245dbd2dfa..07e23557e1dba3 100644 --- a/PCbuild/_testcapi.vcxproj +++ b/PCbuild/_testcapi.vcxproj @@ -94,7 +94,7 @@ - + diff --git a/PCbuild/_testcapi.vcxproj.filters b/PCbuild/_testcapi.vcxproj.filters index c151abea33f50c..82fce057e2e27b 100644 --- a/PCbuild/_testcapi.vcxproj.filters +++ b/PCbuild/_testcapi.vcxproj.filters @@ -12,7 +12,7 @@ Source Files - + Source Files diff --git a/setup.py b/setup.py index 365f97d20904d0..95310aa071f688 100644 --- a/setup.py +++ b/setup.py @@ -994,7 +994,7 @@ def detect_simple_extensions(self): def detect_test_extensions(self): # Python C API test module - self.addext(Extension('_testcapi', ['_testcapimodule.c', '_testcapi/test_vectorcall.c'])) + self.addext(Extension('_testcapi', ['_testcapimodule.c', '_testcapi/vectorcall.c'])) # Python Internal C API test module self.addext(Extension('_testinternalcapi', ['_testinternalcapi.c'])) From c9d78a9019f5c6aff70f540e2de5ac571c5200cb Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Fri, 8 Jul 2022 17:24:09 +0200 Subject: [PATCH 5/5] Style nitpick Co-authored-by: Victor Stinner --- Modules/_testcapimodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index f4ef8492985fc0..436c701a7a3faf 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -7729,7 +7729,7 @@ PyInit__testcapi(void) return NULL; /* Include tests from the _testcapi/ directory */ - if(_PyTestCapi_Init_Vectorcall(m) < 0) { + if (_PyTestCapi_Init_Vectorcall(m) < 0) { return NULL; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy