[Python-checkins] r74625 - in python/trunk: Lib/test/test_descr.py Misc/NEWS Objects/classobject.c Objects/funcobject.c

benjamin.peterson python-checkins at python.org
Wed Sep 2 00:27:58 CEST 2009


Author: benjamin.peterson
Date: Wed Sep  2 00:27:57 2009
New Revision: 74625

Log:
remove the check that classmethod's argument is a callable

Modified:
   python/trunk/Lib/test/test_descr.py
   python/trunk/Misc/NEWS
   python/trunk/Objects/classobject.c
   python/trunk/Objects/funcobject.c

Modified: python/trunk/Lib/test/test_descr.py
==============================================================================
--- python/trunk/Lib/test/test_descr.py	(original)
+++ python/trunk/Lib/test/test_descr.py	Wed Sep  2 00:27:57 2009
@@ -1391,13 +1391,9 @@
         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:

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Wed Sep  2 00:27:57 2009
@@ -12,6 +12,8 @@
 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.
 

Modified: python/trunk/Objects/classobject.c
==============================================================================
--- python/trunk/Objects/classobject.c	(original)
+++ python/trunk/Objects/classobject.c	Wed Sep  2 00:27:57 2009
@@ -2226,10 +2226,6 @@
 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);

Modified: python/trunk/Objects/funcobject.c
==============================================================================
--- python/trunk/Objects/funcobject.c	(original)
+++ python/trunk/Objects/funcobject.c	Wed Sep  2 00:27:57 2009
@@ -659,12 +659,6 @@
 		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;


More information about the Python-checkins mailing list