diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index bef702ebe69..599ca6a4cc0 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -3947,6 +3947,11 @@ PyInit__elementtree(void) st->deepcopy_obj = PyObject_GetAttrString(temp, "deepcopy"); Py_XDECREF(temp); + if (st->deepcopy_obj == NULL) { + return NULL; + } + + assert(!PyErr_Occurred()); if (!(st->elementpath_obj = PyImport_ImportModule("xml.etree.ElementPath"))) return NULL;