bpo-30878: Fix error message when keyword arguments are passed (#2635)

to staticmethod() and classmethod().
diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py
index ca678b9..b004b58 100644
--- a/Lib/test/test_call.py
+++ b/Lib/test/test_call.py
@@ -186,6 +186,14 @@
         msg = r"^pack\(\) takes no keyword arguments$"
         self.assertRaisesRegex(TypeError, msg, struct.Struct.pack, struct.Struct(""), x=2)
 
+    def test_varargs12_kw(self):
+        msg = r"^staticmethod\(\) takes no keyword arguments$"
+        self.assertRaisesRegex(TypeError, msg, staticmethod, func=id)
+
+    def test_varargs13_kw(self):
+        msg = r"^classmethod\(\) takes no keyword arguments$"
+        self.assertRaisesRegex(TypeError, msg, classmethod, func=id)
+
     def test_oldargs0_1(self):
         msg = r"keys\(\) takes no arguments \(1 given\)"
         self.assertRaisesRegex(TypeError, msg, {}.keys, 0)
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 8410001..e440258 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -702,10 +702,10 @@
     classmethod *cm = (classmethod *)self;
     PyObject *callable;
 
-    if (!PyArg_UnpackTuple(args, "classmethod", 1, 1, &callable))
-        return -1;
     if (!_PyArg_NoKeywords("classmethod", kwds))
         return -1;
+    if (!PyArg_UnpackTuple(args, "classmethod", 1, 1, &callable))
+        return -1;
     Py_INCREF(callable);
     cm->cm_callable = callable;
     return 0;
@@ -883,10 +883,10 @@
     staticmethod *sm = (staticmethod *)self;
     PyObject *callable;
 
-    if (!PyArg_UnpackTuple(args, "staticmethod", 1, 1, &callable))
-        return -1;
     if (!_PyArg_NoKeywords("staticmethod", kwds))
         return -1;
+    if (!PyArg_UnpackTuple(args, "staticmethod", 1, 1, &callable))
+        return -1;
     Py_INCREF(callable);
     sm->sm_callable = callable;
     return 0;