summaryrefslogtreecommitdiffstats
path: root/Objects/funcobject.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-12-15 20:34:02 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-12-15 20:34:02 (GMT)
commitbfebb7b54a50f01104f7b6169de77f7fc8feb912 (patch)
treeef88caf96404fbb445d25a695eaa8e51bc750566 /Objects/funcobject.c
parenta8ff01ca7422117dcd906ee2ea55c5293eeceb24 (diff)
downloadcpython-bfebb7b54a50f01104f7b6169de77f7fc8feb912.zip
cpython-bfebb7b54a50f01104f7b6169de77f7fc8feb912.tar.gz
cpython-bfebb7b54a50f01104f7b6169de77f7fc8feb912.tar.bz2
improve abstract property support (closes #11610)
Thanks to Darren Dale for patch.
Diffstat (limited to 'Objects/funcobject.c')
-rw-r--r--Objects/funcobject.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 2839a24..b93f340 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -814,6 +814,27 @@ static PyMemberDef cm_memberlist[] = {
{NULL} /* Sentinel */
};
+static PyObject *
+cm_get___isabstractmethod__(classmethod *cm, void *closure)
+{
+ int res = _PyObject_IsAbstract(cm->cm_callable);
+ if (res == -1) {
+ return NULL;
+ }
+ else if (res) {
+ Py_RETURN_TRUE;
+ }
+ Py_RETURN_FALSE;
+}
+
+static PyGetSetDef cm_getsetlist[] = {
+ {"__isabstractmethod__",
+ (getter)cm_get___isabstractmethod__, NULL,
+ NULL,
+ NULL},
+ {NULL} /* Sentinel */
+};
+
PyDoc_STRVAR(classmethod_doc,
"classmethod(function) -> method\n\
\n\
@@ -865,7 +886,7 @@ PyTypeObject PyClassMethod_Type = {
0, /* tp_iternext */
0, /* tp_methods */
cm_memberlist, /* tp_members */
- 0, /* tp_getset */
+ cm_getsetlist, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
cm_descr_get, /* tp_descr_get */
@@ -969,6 +990,27 @@ static PyMemberDef sm_memberlist[] = {
{NULL} /* Sentinel */
};
+static PyObject *
+sm_get___isabstractmethod__(staticmethod *sm, void *closure)
+{
+ int res = _PyObject_IsAbstract(sm->sm_callable);
+ if (res == -1) {
+ return NULL;
+ }
+ else if (res) {
+ Py_RETURN_TRUE;
+ }
+ Py_RETURN_FALSE;
+}
+
+static PyGetSetDef sm_getsetlist[] = {
+ {"__isabstractmethod__",
+ (getter)sm_get___isabstractmethod__, NULL,
+ NULL,
+ NULL},
+ {NULL} /* Sentinel */
+};
+
PyDoc_STRVAR(staticmethod_doc,
"staticmethod(function) -> method\n\
\n\
@@ -1017,7 +1059,7 @@ PyTypeObject PyStaticMethod_Type = {
0, /* tp_iternext */
0, /* tp_methods */
sm_memberlist, /* tp_members */
- 0, /* tp_getset */
+ sm_getsetlist, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
sm_descr_get, /* tp_descr_get */