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

Modules/_elementtree.c

index 0276452db4c3371802556baa482f6cb15f499bb4..fedef100cec7bfd67c62789b5e66df10a298b53b 100644 (file)
@@ -3952,6 +3952,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;