summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-03-09 15:25:32 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-03-09 15:25:32 (GMT)
commit74529ad3f4a822d10bc9ed2f85875c62989df2c5 (patch)
treeaba559f43205b1945ddd973519120c318b80c226 /Objects/object.c
parent8c43e69bce195d9b5d44d52258995e7a27041bab (diff)
downloadcpython-74529ad3f4a822d10bc9ed2f85875c62989df2c5.zip
cpython-74529ad3f4a822d10bc9ed2f85875c62989df2c5.tar.gz
cpython-74529ad3f4a822d10bc9ed2f85875c62989df2c5.tar.bz2
refactor and avoid warnings
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 08ad68f..69d5f83 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1152,13 +1152,11 @@ _PyObject_GenericSetAttrWithDict(PyObject *obj, PyObject *name,
name->ob_type->tp_name);
return -1;
}
- else
- Py_INCREF(name);
- if (tp->tp_dict == NULL) {
- if (PyType_Ready(tp) < 0)
- goto done;
- }
+ if (tp->tp_dict == NULL && PyType_Ready(tp) < 0)
+ return -1;
+
+ Py_INCREF(name);
descr = _PyType_Lookup(tp, name);
Py_XINCREF(descr);
@@ -1190,9 +1188,9 @@ _PyObject_GenericSetAttrWithDict(PyObject *obj, PyObject *name,
res = PyDict_DelItem(dict, name);
else
res = PyDict_SetItem(dict, name, value);
+ Py_DECREF(dict);
if (res < 0 && PyErr_ExceptionMatches(PyExc_KeyError))
PyErr_SetObject(PyExc_AttributeError, name);
- Py_DECREF(dict);
goto done;
}