summaryrefslogtreecommitdiffstats
path: root/Objects/descrobject.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-08-04 18:03:37 (GMT)
committerGeorg Brandl <georg@python.org>2006-08-04 18:03:37 (GMT)
commite9462c72bd3db9daca682bc7f993f9c77a4022db (patch)
tree1c098858248eb7f7336cb427a64c31feb362f1bf /Objects/descrobject.c
parent06ded09d4048bf44ce9b61c82494cf0a0825412c (diff)
downloadcpython-e9462c72bd3db9daca682bc7f993f9c77a4022db.zip
cpython-e9462c72bd3db9daca682bc7f993f9c77a4022db.tar.gz
cpython-e9462c72bd3db9daca682bc7f993f9c77a4022db.tar.bz2
Change fix for segfaulting property(), add a NEWS entry and a test.
Diffstat (limited to 'Objects/descrobject.c')
-rw-r--r--Objects/descrobject.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 1fe6281..914b6d3 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1190,19 +1190,21 @@ property_init(PyObject *self, PyObject *args, PyObject *kwds)
if (del == Py_None)
del = NULL;
- /* if no docstring given and the getter has one, use that one */
- if ((doc == NULL || doc == Py_None) && get != NULL &&
- PyObject_HasAttrString(get, "__doc__")) {
- doc = PyObject_GetAttrString(get, "__doc__");
- if (doc == NULL)
- return -1;
- } else {
- Py_XINCREF(doc);
- }
-
Py_XINCREF(get);
Py_XINCREF(set);
Py_XINCREF(del);
+ Py_XINCREF(doc);
+
+ /* if no docstring given and the getter has one, use that one */
+ if ((doc == NULL || doc == Py_None) && get != NULL) {
+ PyObject *get_doc = PyObject_GetAttrString(get, "__doc__");
+ if (get_doc != NULL) {
+ Py_XDECREF(doc);
+ doc = get_doc; /* get_doc already INCREF'd by GetAttr */
+ } else {
+ PyErr_Clear();
+ }
+ }
gs->prop_get = get;
gs->prop_set = set;