diff options
author | Eli Bendersky <eliben@gmail.com> | 2013-05-18 14:53:47 (GMT) |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2013-05-18 14:53:47 (GMT) |
commit | 1a8c3e247a2c41c1f3a9eceb39bb0e9e5a3d0c6f (patch) | |
tree | 05d03b277db0f10705c5cb60b6bcb37c29841335 /Modules/_elementtree.c | |
parent | 163e9821b4644113e5aa4314e3c2e5b1b394e5f7 (diff) | |
parent | ef9683b73f8980fb7cfa39166670d3998b092804 (diff) | |
download | cpython-1a8c3e247a2c41c1f3a9eceb39bb0e9e5a3d0c6f.zip cpython-1a8c3e247a2c41c1f3a9eceb39bb0e9e5a3d0c6f.tar.gz cpython-1a8c3e247a2c41c1f3a9eceb39bb0e9e5a3d0c6f.tar.bz2 |
Issue #17989: element_setattro returned incorrect error value.
This caused an exception to be raised later than expected.
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r-- | Modules/_elementtree.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index f5b0914..7c8f5d5 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1768,17 +1768,16 @@ element_getattro(ElementObject* self, PyObject* nameobj) return res; } -static PyObject* +static int element_setattro(ElementObject* self, PyObject* nameobj, PyObject* value) { char *name = ""; if (PyUnicode_Check(nameobj)) name = _PyUnicode_AsString(nameobj); - if (name == NULL) - return NULL; - - if (strcmp(name, "tag") == 0) { + if (name == NULL) { + return -1; + } else if (strcmp(name, "tag") == 0) { Py_DECREF(self->tag); self->tag = value; Py_INCREF(self->tag); @@ -1797,11 +1796,12 @@ element_setattro(ElementObject* self, PyObject* nameobj, PyObject* value) self->extra->attrib = value; Py_INCREF(self->extra->attrib); } else { - PyErr_SetString(PyExc_AttributeError, name); - return NULL; + PyErr_SetString(PyExc_AttributeError, + "Can't set arbitraty attributes on Element"); + return -1; } - return NULL; + return 0; } static PySequenceMethods element_as_sequence = { |