Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit 2ee9640

Browse files
author
gvanrossum
committed
Add 'state' as a get/set attribute to spamlist. This serves as an
example. git-svn-id: http://svn.python.org/projects/python/trunk@22490 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent abd9d9d commit 2ee9640

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

Modules/xxsubtype.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ spamlist_init(spamlistobject *self, PyObject *args, PyObject *kwds)
4949
return 0;
5050
}
5151

52+
static PyObject *
53+
spamlist_state_get(spamlistobject *self)
54+
{
55+
return PyInt_FromLong(self->state);
56+
}
57+
58+
static struct getsetlist spamlist_getsets[] = {
59+
{"state", (getter)spamlist_state_get, NULL, NULL},
60+
{0}
61+
};
62+
5263
static PyTypeObject spamlist_type = {
5364
PyObject_HEAD_INIT(&PyType_Type)
5465
0,
@@ -80,7 +91,7 @@ static PyTypeObject spamlist_type = {
8091
0, /* tp_iternext */
8192
spamlist_methods, /* tp_methods */
8293
0, /* tp_members */
83-
0, /* tp_getset */
94+
spamlist_getsets, /* tp_getset */
8495
&PyList_Type, /* tp_base */
8596
0, /* tp_dict */
8697
0, /* tp_descr_get */

0 commit comments

Comments
 (0)