mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #25019: Fixed a crash caused by setting non-string key of expat parser.
Added additional tests for expat parser attributes. Based on patch by John Leitch.
This commit is contained in:
commit
3b1bc7828d
4 changed files with 51 additions and 16 deletions
|
@ -1378,11 +1378,16 @@ static int
|
|||
xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v)
|
||||
{
|
||||
/* Set attribute 'name' to value 'v'. v==NULL means delete */
|
||||
if (!PyUnicode_Check(name)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"attribute name must be string, not '%.200s'",
|
||||
name->ob_type->tp_name);
|
||||
return -1;
|
||||
}
|
||||
if (v == NULL) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Cannot delete attribute");
|
||||
return -1;
|
||||
}
|
||||
assert(PyUnicode_Check(name));
|
||||
if (PyUnicode_CompareWithASCIIString(name, "buffer_text") == 0) {
|
||||
int b = PyObject_IsTrue(v);
|
||||
if (b < 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue