summaryrefslogtreecommitdiffstats
path: root/Modules/_elementtree.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-11 21:05:03 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-11 21:05:03 (GMT)
commit4d463433404fc9c3385d6afebab41352f2fbc6f8 (patch)
treeb05e9d49d25eac028ea68e50092ef1256f12f778 /Modules/_elementtree.c
parent5f0af23f5ebd3d1ad6eea63bad238d7168ee61a2 (diff)
downloadcpython-4d463433404fc9c3385d6afebab41352f2fbc6f8.zip
cpython-4d463433404fc9c3385d6afebab41352f2fbc6f8.tar.gz
cpython-4d463433404fc9c3385d6afebab41352f2fbc6f8.tar.bz2
Cleanup _elementtree.c
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r--Modules/_elementtree.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 1957abf..a5b3ec5 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -529,7 +529,6 @@ subelement(PyObject *self, PyObject *args, PyObject *kwds)
}
elem = create_new_element(tag, attrib);
-
Py_DECREF(attrib);
if (element_add_subelement(parent, elem) < 0) {
@@ -1784,10 +1783,10 @@ element_setattro(ElementObject* self, PyObject* nameobj, PyObject* value)
char *name = "";
if (PyUnicode_Check(nameobj))
name = _PyUnicode_AsString(nameobj);
-
- if (name == NULL) {
+ if (name == NULL)
return -1;
- } else if (strcmp(name, "tag") == 0) {
+
+ if (strcmp(name, "tag") == 0) {
Py_DECREF(self->tag);
self->tag = value;
Py_INCREF(self->tag);
@@ -2135,15 +2134,15 @@ create_elementiter(ElementObject *self, PyObject *tag, int gettext)
if (star && PyObject_RichCompareBool(tag, star, Py_EQ) == 1)
tag = Py_None;
-
Py_XDECREF(star);
+
+ Py_INCREF(tag);
it->sought_tag = tag;
it->root_done = 0;
it->gettext = gettext;
+ Py_INCREF(self);
it->root_element = self;
- Py_INCREF(self);
- Py_INCREF(tag);
PyObject_GC_Track(it);
return (PyObject *)it;