diff --git "a/.\\Python-3.5.0rc1/Lib/test/test_pyexpat.py" "b/.\\Python-3.5.0rc1/Lib/test/test_pyexpat.py" index 08e95c6..9482f85 100644 --- "a/.\\Python-3.5.0rc1/Lib/test/test_pyexpat.py" +++ "b/.\\Python-3.5.0rc1/Lib/test/test_pyexpat.py" @@ -499,6 +499,18 @@ class sf1296433Test(unittest.TestCase): parser.CharacterDataHandler = handler self.assertRaises(Exception, parser.Parse, xml.encode('iso8859')) + +class ParserCreateSetAttrBugTest(unittest.TestCase): + # http://bugs.python.org/issue25019 + def test_setattr_valid_name(self): + parser = expat.ParserCreate() + self.assertFalse(parser.buffer_text) + parser.__setattr__("buffer_text", True) + self.assertTrue(parser.buffer_text) + + def test_setattr_invalid_name(self): + parser = expat.ParserCreate() + self.assertRaises(TypeError, parser.__setattr__, range(0xF), 0) class ChardataBufferTest(unittest.TestCase): """ diff --git "a/.\\Python-3.5.0rc1/Modules/pyexpat.c" "b/.\\Python-3.5.0rc1/Modules/pyexpat.c" index a43887e..145f494 100644 --- "a/.\\Python-3.5.0rc1/Modules/pyexpat.c" +++ "b/.\\Python-3.5.0rc1/Modules/pyexpat.c" @@ -1382,7 +1382,10 @@ xmlparse_setattro(xmlparseobject *self, PyObject *name, PyObject *v) PyErr_SetString(PyExc_RuntimeError, "Cannot delete attribute"); return -1; } - assert(PyUnicode_Check(name)); + if (!PyUnicode_Check(name)) { + PyErr_SetString(PyExc_TypeError, "name must be a string"); + return -1; + } if (PyUnicode_CompareWithASCIIString(name, "buffer_text") == 0) { int b = PyObject_IsTrue(v); if (b < 0)