bpo-30892: Fix _elementtree module initialization (#2647)

Handle getattr(copy, 'deepcopy') error in _elementtree module
initialization.
This commit is contained in:
Victor Stinner 2017-07-10 22:28:02 +02:00 committed by GitHub
parent aa8d0a2469
commit b136f11f3a
1 changed files with 5 additions and 0 deletions

View File

@ -3990,6 +3990,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;