improve abstract property support (closes #11610)
Thanks to Darren Dale for patch.
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 32b1593..1268df9 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1380,6 +1380,43 @@
return 0;
}
+static PyObject *
+property_get___isabstractmethod__(propertyobject *prop, void *closure)
+{
+ int res = _PyObject_IsAbstract(prop->prop_get);
+ if (res == -1) {
+ return NULL;
+ }
+ else if (res) {
+ Py_RETURN_TRUE;
+ }
+
+ res = _PyObject_IsAbstract(prop->prop_set);
+ if (res == -1) {
+ return NULL;
+ }
+ else if (res) {
+ Py_RETURN_TRUE;
+ }
+
+ res = _PyObject_IsAbstract(prop->prop_del);
+ if (res == -1) {
+ return NULL;
+ }
+ else if (res) {
+ Py_RETURN_TRUE;
+ }
+ Py_RETURN_FALSE;
+}
+
+static PyGetSetDef property_getsetlist[] = {
+ {"__isabstractmethod__",
+ (getter)property_get___isabstractmethod__, NULL,
+ NULL,
+ NULL},
+ {NULL} /* Sentinel */
+};
+
PyDoc_STRVAR(property_doc,
"property(fget=None, fset=None, fdel=None, doc=None) -> property attribute\n"
"\n"
@@ -1445,7 +1482,7 @@
0, /* tp_iternext */
property_methods, /* tp_methods */
property_members, /* tp_members */
- 0, /* tp_getset */
+ property_getsetlist, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
property_descr_get, /* tp_descr_get */