From 9cc5d44812434431780ddc029e3a7c419ecbd8a6 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 30 Oct 2018 13:54:36 +0200 Subject: [PATCH 1/2] Fix a compiler warning introduced in GH-9084. --- Modules/_testcapimodule.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 56a08a418b361f..0fda9185351177 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -4584,20 +4584,20 @@ new_hamt(PyObject *self, PyObject *args) return repr(self) */ static PyObject* -bad_get(PyObject *module, PyObject *const *args, Py_ssize_t nargs) +bad_get(PyObject *module, PyObject *args) { - if (nargs != 3) { - PyErr_SetString(PyExc_TypeError, "bad_get requires exactly 3 arguments"); + PyObject *self, *obj, *cls; + if (!PyArg_UnpackTuple(args, "bad_get", 3, 3, &self, &obj, &cls)) { return NULL; } - PyObject *res = PyObject_CallObject(args[2], NULL); + PyObject *res = PyObject_CallObject(cls, NULL); if (res == NULL) { return NULL; } Py_DECREF(res); - return PyObject_Repr(args[0]); + return PyObject_Repr(self); } @@ -4960,7 +4960,7 @@ static PyMethodDef TestMethods[] = { {"get_mapping_items", get_mapping_items, METH_O}, {"test_pythread_tss_key_state", test_pythread_tss_key_state, METH_VARARGS}, {"hamt", new_hamt, METH_NOARGS}, - {"bad_get", bad_get, METH_FASTCALL}, + {"bad_get", bad_get, METH_VARARGS}, {"EncodeLocaleEx", encode_locale_ex, METH_VARARGS}, {"DecodeLocaleEx", decode_locale_ex, METH_VARARGS}, {"get_global_config", get_global_config, METH_NOARGS}, From cbd37d19cad6ad919eca570b9ce53e0799a4e15e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 20 Nov 2018 19:38:47 +0200 Subject: [PATCH 2/2] Use METH_FASTCALL. --- Modules/_testcapimodule.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 0fda9185351177..0dc4d7a36b7667 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -4584,10 +4584,10 @@ new_hamt(PyObject *self, PyObject *args) return repr(self) */ static PyObject* -bad_get(PyObject *module, PyObject *args) +bad_get(PyObject *module, PyObject *const *args, Py_ssize_t nargs) { PyObject *self, *obj, *cls; - if (!PyArg_UnpackTuple(args, "bad_get", 3, 3, &self, &obj, &cls)) { + if (!_PyArg_UnpackStack(args, nargs, "bad_get", 3, 3, &self, &obj, &cls)) { return NULL; } @@ -4960,7 +4960,7 @@ static PyMethodDef TestMethods[] = { {"get_mapping_items", get_mapping_items, METH_O}, {"test_pythread_tss_key_state", test_pythread_tss_key_state, METH_VARARGS}, {"hamt", new_hamt, METH_NOARGS}, - {"bad_get", bad_get, METH_VARARGS}, + {"bad_get", (PyCFunction)bad_get, METH_FASTCALL}, {"EncodeLocaleEx", encode_locale_ex, METH_VARARGS}, {"DecodeLocaleEx", decode_locale_ex, METH_VARARGS}, {"get_global_config", get_global_config, METH_NOARGS},