diff options
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/classobject.c | 8 | ||||
-rw-r--r-- | Objects/descrobject.c | 29 | ||||
-rw-r--r-- | Objects/fileobject.c | 4 | ||||
-rw-r--r-- | Objects/frameobject.c | 2 | ||||
-rw-r--r-- | Objects/funcobject.c | 2 | ||||
-rw-r--r-- | Objects/methodobject.c | 2 | ||||
-rw-r--r-- | Objects/typeobject.c | 6 |
7 files changed, 34 insertions, 19 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index f8ee6fd..df10aa2 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -2036,10 +2036,10 @@ im_get_name(PyMethodObject *im) return PyObject_GetAttrString(im->im_func, "__name__"); } -static struct getsetlist instancemethod_getsetlist[] = { - {"__dict__", (getter)im_get_dict}, - {"__doc__", (getter)im_get_doc}, - {"__name__", (getter)im_get_name}, +static PyGetSetDef instancemethod_getsetlist[] = { + {"__dict__", (getter)im_get_dict, NULL, "same as im_func.__dict__"}, + {"__doc__", (getter)im_get_doc, NULL, "same as im_func.__doc__"}, + {"__name__", (getter)im_get_name, NULL, "same as im_func.__name__"}, {NULL} /* Sentinel */ }; diff --git a/Objects/descrobject.c b/Objects/descrobject.c index dfbb3b6..7be1074 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -26,7 +26,7 @@ typedef struct { typedef struct { COMMON; - struct getsetlist *d_getset; + PyGetSetDef *d_getset; } PyGetSetDescrObject; typedef struct { @@ -302,7 +302,7 @@ static PyMemberDef descr_members[] = { {0} }; -static struct getsetlist method_getset[] = { +static PyGetSetDef method_getset[] = { {"__doc__", (getter)method_get_doc}, {0} }; @@ -317,12 +317,27 @@ member_get_doc(PyMemberDescrObject *descr, void *closure) return PyString_FromString(descr->d_member->doc); } -static struct getsetlist member_getset[] = { +static PyGetSetDef member_getset[] = { {"__doc__", (getter)member_get_doc}, {0} }; static PyObject * +getset_get_doc(PyGetSetDescrObject *descr, void *closure) +{ + if (descr->d_getset->doc == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + return PyString_FromString(descr->d_getset->doc); +} + +static PyGetSetDef getset_getset[] = { + {"__doc__", (getter)getset_get_doc}, + {0} +}; + +static PyObject * wrapper_get_doc(PyWrapperDescrObject *descr, void *closure) { if (descr->d_base->doc == NULL) { @@ -332,7 +347,7 @@ wrapper_get_doc(PyWrapperDescrObject *descr, void *closure) return PyString_FromString(descr->d_base->doc); } -static struct getsetlist wrapper_getset[] = { +static PyGetSetDef wrapper_getset[] = { {"__doc__", (getter)wrapper_get_doc}, {0} }; @@ -444,7 +459,7 @@ static PyTypeObject PyGetSetDescr_Type = { 0, /* tp_iternext */ 0, /* tp_methods */ descr_members, /* tp_members */ - 0, /* tp_getset */ + getset_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ (descrgetfunc)getset_get, /* tp_descr_get */ @@ -532,7 +547,7 @@ PyDescr_NewMember(PyTypeObject *type, PyMemberDef *member) } PyObject * -PyDescr_NewGetSet(PyTypeObject *type, struct getsetlist *getset) +PyDescr_NewGetSet(PyTypeObject *type, PyGetSetDef *getset) { PyGetSetDescrObject *descr; @@ -778,7 +793,7 @@ wrapper_doc(wrapperobject *wp) } } -static struct getsetlist wrapper_getsets[] = { +static PyGetSetDef wrapper_getsets[] = { {"__name__", (getter)wrapper_name}, {"__doc__", (getter)wrapper_doc}, {0} diff --git a/Objects/fileobject.c b/Objects/fileobject.c index 5c879ff..b6c039c 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -1400,8 +1400,8 @@ get_closed(PyFileObject *f, void *closure) return PyInt_FromLong((long)(f->f_fp == 0)); } -static struct getsetlist file_getsetlist[] = { - {"closed", (getter)get_closed, NULL, NULL}, +static PyGetSetDef file_getsetlist[] = { + {"closed", (getter)get_closed, NULL, "flag set if the file is closed"}, {0}, }; diff --git a/Objects/frameobject.c b/Objects/frameobject.c index cb7e80a..e092ce6 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -33,7 +33,7 @@ frame_getlocals(PyFrameObject *f, void *closure) return f->f_locals; } -static struct getsetlist frame_getsetlist[] = { +static PyGetSetDef frame_getsetlist[] = { {"f_locals", (getter)frame_getlocals, NULL, NULL}, {0} }; diff --git a/Objects/funcobject.c b/Objects/funcobject.c index e1cf080..4e77d52 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -257,7 +257,7 @@ func_set_defaults(PyFunctionObject *op, PyObject *value) return 0; } -static struct getsetlist func_getsetlist[] = { +static PyGetSetDef func_getsetlist[] = { {"func_code", (getter)func_get_code, (setter)func_set_code}, {"func_defaults", (getter)func_get_defaults, (setter)func_set_defaults}, diff --git a/Objects/methodobject.c b/Objects/methodobject.c index 5fe9178..e0968af 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -159,7 +159,7 @@ meth_get__self__(PyCFunctionObject *m, void *closure) return self; } -static struct getsetlist meth_getsets [] = { +static PyGetSetDef meth_getsets [] = { {"__doc__", (getter)meth_get__doc__, NULL, NULL}, {"__name__", (getter)meth_get__name__, NULL, NULL}, {"__self__", (getter)meth_get__self__, NULL, NULL}, diff --git a/Objects/typeobject.c b/Objects/typeobject.c index b53555d..9e6d3df 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -91,7 +91,7 @@ type_dynamic(PyTypeObject *type, void *context) return res; } -struct getsetlist type_getsets[] = { +PyGetSetDef type_getsets[] = { {"__name__", (getter)type_name, NULL, NULL}, {"__module__", (getter)type_module, NULL, NULL}, {"__dict__", (getter)type_dict, NULL, NULL}, @@ -659,7 +659,7 @@ subtype_dict(PyObject *obj, void *context) } } -struct getsetlist subtype_getsets[] = { +PyGetSetDef subtype_getsets[] = { {"__dict__", subtype_dict, NULL, NULL}, {0}, }; @@ -1282,7 +1282,7 @@ add_members(PyTypeObject *type, PyMemberDef *memb) } static int -add_getset(PyTypeObject *type, struct getsetlist *gsp) +add_getset(PyTypeObject *type, PyGetSetDef *gsp) { PyObject *dict = type->tp_defined; |