mirror of
https://github.com/python/cpython.git
synced 2025-12-05 00:52:25 +00:00
gh-105375: Improve error handling in _elementtree (#105591)
Fix bugs where exceptions could end up being overwritten.
This commit is contained in:
parent
f668f73bc8
commit
00b599ab5a
2 changed files with 8 additions and 3 deletions
|
|
@ -0,0 +1 @@
|
||||||
|
Fix bugs in :mod:`!_elementtree` where exceptions could be overwritten.
|
||||||
|
|
@ -3259,10 +3259,14 @@ expat_start_handler(XMLParserObject* self, const XML_Char* tag_in,
|
||||||
}
|
}
|
||||||
while (attrib_in[0] && attrib_in[1]) {
|
while (attrib_in[0] && attrib_in[1]) {
|
||||||
PyObject* key = makeuniversal(self, attrib_in[0]);
|
PyObject* key = makeuniversal(self, attrib_in[0]);
|
||||||
|
if (key == NULL) {
|
||||||
|
Py_DECREF(attrib);
|
||||||
|
Py_DECREF(tag);
|
||||||
|
return;
|
||||||
|
}
|
||||||
PyObject* value = PyUnicode_DecodeUTF8(attrib_in[1], strlen(attrib_in[1]), "strict");
|
PyObject* value = PyUnicode_DecodeUTF8(attrib_in[1], strlen(attrib_in[1]), "strict");
|
||||||
if (!key || !value) {
|
if (value == NULL) {
|
||||||
Py_XDECREF(value);
|
Py_DECREF(key);
|
||||||
Py_XDECREF(key);
|
|
||||||
Py_DECREF(attrib);
|
Py_DECREF(attrib);
|
||||||
Py_DECREF(tag);
|
Py_DECREF(tag);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue