From 6fcf9b50bc13d757096822ba996fa3c122b70c6b Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Tue, 1 Sep 2009 22:27:57 +0000 Subject: remove the check that classmethod's argument is a callable --- Lib/test/test_descr.py | 10 +++------- Misc/NEWS | 2 ++ Objects/classobject.c | 4 ---- Objects/funcobject.c | 6 ------ 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 6dc27be..00f19ce 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -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: diff --git a/Misc/NEWS b/Misc/NEWS index 3b0bd5c..dfb2e22 100644 --- 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. diff --git a/Objects/classobject.c b/Objects/classobject.c index 7d3d048..3f51c0f 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -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); diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 7774e6d..075f820 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -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; -- cgit v0.12