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

Handle getattr(copy, 'deepcopy') error in _elementtree module
initialization.
(cherry picked from commit b136f11f3a)
This commit is contained in:
Victor Stinner 2017-07-10 23:12:37 +02:00 committed by GitHub
parent 8e3f73e549
commit 044e156426
1 changed files with 5 additions and 0 deletions

View File

@ -3947,6 +3947,11 @@ PyInit__elementtree(void)
st->deepcopy_obj = PyObject_GetAttrString(temp, "deepcopy"); st->deepcopy_obj = PyObject_GetAttrString(temp, "deepcopy");
Py_XDECREF(temp); Py_XDECREF(temp);
if (st->deepcopy_obj == NULL) {
return NULL;
}
assert(!PyErr_Occurred());
if (!(st->elementpath_obj = PyImport_ImportModule("xml.etree.ElementPath"))) if (!(st->elementpath_obj = PyImport_ImportModule("xml.etree.ElementPath")))
return NULL; return NULL;