diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index 88374cc3521..2fad8e2f475 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -2734,6 +2734,8 @@ xmlparser_setevents(XMLParserObject* self, PyObject* args) char* event; if (PyUnicode_Check(item)) { event = _PyUnicode_AsString(item); + if (event == NULL) + goto error; } else if (PyBytes_Check(item)) event = PyBytes_AS_STRING(item); else {