mirror of
https://github.com/python/cpython.git
synced 2025-08-01 23:53:15 +00:00
Issue #17989: element_setattro returned incorrect error value.
This caused an exception to be raised later than expected.
This commit is contained in:
parent
587d3bf78a
commit
ef9683b73f
1 changed files with 8 additions and 8 deletions
|
@ -1808,17 +1808,16 @@ element_getattro(ElementObject* self, PyObject* nameobj)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject*
|
static int
|
||||||
element_setattro(ElementObject* self, PyObject* nameobj, PyObject* value)
|
element_setattro(ElementObject* self, PyObject* nameobj, PyObject* value)
|
||||||
{
|
{
|
||||||
char *name = "";
|
char *name = "";
|
||||||
if (PyUnicode_Check(nameobj))
|
if (PyUnicode_Check(nameobj))
|
||||||
name = _PyUnicode_AsString(nameobj);
|
name = _PyUnicode_AsString(nameobj);
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL) {
|
||||||
return NULL;
|
return -1;
|
||||||
|
} else if (strcmp(name, "tag") == 0) {
|
||||||
if (strcmp(name, "tag") == 0) {
|
|
||||||
Py_DECREF(self->tag);
|
Py_DECREF(self->tag);
|
||||||
self->tag = value;
|
self->tag = value;
|
||||||
Py_INCREF(self->tag);
|
Py_INCREF(self->tag);
|
||||||
|
@ -1837,11 +1836,12 @@ element_setattro(ElementObject* self, PyObject* nameobj, PyObject* value)
|
||||||
self->extra->attrib = value;
|
self->extra->attrib = value;
|
||||||
Py_INCREF(self->extra->attrib);
|
Py_INCREF(self->extra->attrib);
|
||||||
} else {
|
} else {
|
||||||
PyErr_SetString(PyExc_AttributeError, name);
|
PyErr_SetString(PyExc_AttributeError,
|
||||||
return NULL;
|
"Can't set arbitraty attributes on Element");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PySequenceMethods element_as_sequence = {
|
static PySequenceMethods element_as_sequence = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue