Restore behaviors before classmethod descriptor chaining was introduced.
gc.collect()
self.assertEqual(Parent.__subclasses__(), [])
+ def test_instance_method_get_behavior(self):
+ # test case for gh-113157
+
+ class A:
+ def meth(self):
+ return self
+
+ class B:
+ pass
+
+ a = A()
+ b = B()
+ b.meth = a.meth.__get__(b, B)
+ self.assertEqual(b.meth(), a)
+
def test_attr_raise_through_property(self):
# test case for gh-103272
class A:
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",
.tp_methods = method_methods,
.tp_members = method_memberlist,
.tp_getset = method_getset,
+ .tp_descr_get = method_descr_get,
.tp_new = method_new,
};