mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Add 'state' as a read-only attribute to spamdict. This serves as an
example.
This commit is contained in:
parent
23cc2b4991
commit
e6b90eaea1
1 changed files with 7 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
|
#include "structmember.h"
|
||||||
|
|
||||||
/* Examples showing how to subtype the builtin list and dict types from C. */
|
/* Examples showing how to subtype the builtin list and dict types from C. */
|
||||||
|
|
||||||
|
|
@ -136,6 +137,11 @@ spamdict_init(spamdictobject *self, PyObject *args, PyObject *kwds)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct memberlist spamdict_members[] = {
|
||||||
|
{"state", T_INT, offsetof(spamdictobject, state), READONLY},
|
||||||
|
{0}
|
||||||
|
};
|
||||||
|
|
||||||
static PyTypeObject spamdict_type = {
|
static PyTypeObject spamdict_type = {
|
||||||
PyObject_HEAD_INIT(&PyType_Type)
|
PyObject_HEAD_INIT(&PyType_Type)
|
||||||
0,
|
0,
|
||||||
|
|
@ -166,7 +172,7 @@ static PyTypeObject spamdict_type = {
|
||||||
0, /* tp_iter */
|
0, /* tp_iter */
|
||||||
0, /* tp_iternext */
|
0, /* tp_iternext */
|
||||||
spamdict_methods, /* tp_methods */
|
spamdict_methods, /* tp_methods */
|
||||||
0, /* tp_members */
|
spamdict_members, /* tp_members */
|
||||||
0, /* tp_getset */
|
0, /* tp_getset */
|
||||||
&PyDict_Type, /* tp_base */
|
&PyDict_Type, /* tp_base */
|
||||||
0, /* tp_dict */
|
0, /* tp_dict */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue