]> granicus.if.org Git - python/commitdiff
bpo-30892: Fix _elementtree module initialization (#2647) (#2649)
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 10 Jul 2017 21:12:37 +0000 (23:12 +0200)
committerGitHub <noreply@github.com>
Mon, 10 Jul 2017 21:12:37 +0000 (23:12 +0200)
Handle getattr(copy, 'deepcopy') error in _elementtree module
initialization.
(cherry picked from commit b136f11f3a51f9282ae992bac68f170ca5563b55)

Modules/_elementtree.c

index bef702ebe69c93376e766082f87987594dc075a8..599ca6a4cc0d7c9fe47fd8f442ae4e17c483ed1d 100644 (file)
@@ -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;