def test_mixing_slot_wrappers(self):
class X(dict):
__setattr__ = dict.__setitem__
+ __neg__ = dict.copy
x = X()
x.y = 42
self.assertEqual(x["y"], 42)
+ self.assertEqual(x, -x)
def test_slot_shadows_class_variable(self):
with self.assertRaises(ValueError) as cm:
--- /dev/null
+Slot functions optimize any callable with ``Py_TPFLAGS_METHOD_DESCRIPTOR`` instead of only instances of ``function``.
\ No newline at end of file
return NULL;
}
- if (PyFunction_Check(res)) {
+ if (PyType_HasFeature(Py_TYPE(res), Py_TPFLAGS_METHOD_DESCRIPTOR)) {
/* Avoid temporary PyMethodObject */
*unbound = 1;
Py_INCREF(res);