]> granicus.if.org Git - python/commitdiff
remove the check that classmethod's argument is a callable
authorBenjamin Peterson <benjamin@python.org>
Tue, 1 Sep 2009 22:27:57 +0000 (22:27 +0000)
committerBenjamin Peterson <benjamin@python.org>
Tue, 1 Sep 2009 22:27:57 +0000 (22:27 +0000)
Lib/test/test_descr.py
Misc/NEWS
Objects/classobject.c
Objects/funcobject.c

index 6dc27bec4f91faec12d11931f9a01b71a7461660..00f19ce17bb70a6b32a1094df53e350364a626da 100644 (file)
@@ -1391,13 +1391,9 @@ order (MRO) for bases """
         self.assertEqual(super(D,D).goo(), (D,))
         self.assertEqual(super(D,d).goo(), (D,))
 
-        # Verify that argument is checked for callability (SF bug 753451)
-        try:
-            classmethod(1).__get__(1)
-        except TypeError:
-            pass
-        else:
-            self.fail("classmethod should check for callability")
+        # Verify that a non-callable will raise
+        meth = classmethod(1).__get__(1)
+        self.assertRaises(TypeError, meth)
 
         # Verify that classmethod() doesn't allow keyword args
         try:
index 3b0bd5c538f5f57f7f6833a60374121d9b219e7d..dfb2e223e473a3084072029dd2cb141c899cd624 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 1
 Core and Builtins
 -----------------
 
+- classmethod no longer checks if its argument is callable.
+
 - Issue #6750: A text file opened with io.open() could duplicate its output
   when writing from multiple threads at the same time.
 
index 7d3d0480b513f23769e60bc784fe5cc92fb56749..3f51c0fc55cc4aa5d6596e92913764a53c290cd3 100644 (file)
@@ -2226,10 +2226,6 @@ PyObject *
 PyMethod_New(PyObject *func, PyObject *self, PyObject *klass)
 {
        register PyMethodObject *im;
-       if (!PyCallable_Check(func)) {
-               PyErr_BadInternalCall();
-               return NULL;
-       }
        im = free_list;
        if (im != NULL) {
                free_list = (PyMethodObject *)(im->im_self);
index 7774e6d1e5e2baa6ecbe039632281f405a9bec98..075f82012d8837a298b6e3b1653abff142bdffbf 100644 (file)
@@ -659,12 +659,6 @@ cm_init(PyObject *self, PyObject *args, PyObject *kwds)
                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);
-               return -1;
-       }
-       
        Py_INCREF(callable);
        cm->cm_callable = callable;
        return 0;