From: Victor Stinner Date: Mon, 10 Jul 2017 20:28:02 +0000 (+0200) Subject: bpo-30892: Fix _elementtree module initialization (#2647) X-Git-Tag: v3.7.0a1~439 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b136f11f3a51f9282ae992bac68f170ca5563b55;p=python bpo-30892: Fix _elementtree module initialization (#2647) Handle getattr(copy, 'deepcopy') error in _elementtree module initialization. --- diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index eaa9e873d2..3537f19b1c 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -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;