Skip to content

Commit 7f567e7

Browse files
authored
bpo-30892: Fix _elementtree module initialization (#2647) (#2650)
Handle getattr(copy, 'deepcopy') error in _elementtree module initialization. (cherry picked from commit b136f11)
1 parent 69e4180 commit 7f567e7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Modules/_elementtree.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3952,6 +3952,11 @@ PyInit__elementtree(void)
39523952
st->deepcopy_obj = PyObject_GetAttrString(temp, "deepcopy");
39533953
Py_XDECREF(temp);
39543954

3955+
if (st->deepcopy_obj == NULL) {
3956+
return NULL;
3957+
}
3958+
3959+
assert(!PyErr_Occurred());
39553960
if (!(st->elementpath_obj = PyImport_ImportModule("xml.etree.ElementPath")))
39563961
return NULL;
39573962

0 commit comments

Comments
 (0)