Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Lib/test/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ def outer(cls):
self.assertEqual(Class().inner(), 'spam')
self.assertEqual(Class().outer(), 'eggs')

def test_bound_function_inside_classmethod(self):
class A:
def foo(self, cls):
return 'spam'

class B:
bar = classmethod(A().foo)

self.assertEqual(B.bar(), 'spam')

def test_wrapped_classmethod_inside_classmethod(self):
class MyClassMethod1:
def __init__(self, func):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix wrapping bound methods with @classmethod
8 changes: 0 additions & 8 deletions Objects/classobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,6 @@ method_traverse(PyMethodObject *im, visitproc visit, void *arg)
return 0;
}

static PyObject *
method_descr_get(PyObject *meth, PyObject *obj, PyObject *cls)
{
Py_INCREF(meth);
return meth;
}

PyTypeObject PyMethod_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "method",
Expand All @@ -348,7 +341,6 @@ PyTypeObject PyMethod_Type = {
.tp_methods = method_methods,
.tp_members = method_memberlist,
.tp_getset = method_getset,
.tp_descr_get = method_descr_get,
.tp_new = method_new,
};

Expand Down