From c6994f2502a39c5dbc201c62676c6cc9411675fd Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Tue, 3 Oct 2006 18:25:19 +0000 Subject: [PATCH] [Backport rev. 42545 by georg.brandl] Make staticmethod and classmethod complain about keyword args. --- Misc/NEWS | 3 +++ Objects/funcobject.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index bc48b007b2d6..2a6145c72c0c 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -16,6 +16,9 @@ Core and builtins keyword arguments any more (previously they accepted them, but didn't use them). +- staticmethod() and classmethod() also now complain about keyword args + instead of silently ignoring them. + - Bug #1331062: Fix error in UTF-7 codec. - Bug #1365916: Fix an int/long mismatch in the sorted() built-in. diff --git a/Objects/funcobject.c b/Objects/funcobject.c index c0c91c95d17d..36c1ba86f6c5 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -684,6 +684,8 @@ cm_init(PyObject *self, PyObject *args, PyObject *kwds) if (!PyArg_UnpackTuple(args, "classmethod", 1, 1, &callable)) return -1; + if (!_PyArg_NoKeywords("classmethod", kwds)) + return -1; if (!PyCallable_Check(callable)) { PyErr_Format(PyExc_TypeError, "'%s' object is not callable", callable->ob_type->tp_name); @@ -840,6 +842,8 @@ sm_init(PyObject *self, PyObject *args, PyObject *kwds) if (!PyArg_UnpackTuple(args, "staticmethod", 1, 1, &callable)) return -1; + if (!_PyArg_NoKeywords("staticmethod", kwds)) + return -1; Py_INCREF(callable); sm->sm_callable = callable; return 0; -- 2.47.3