]> granicus.if.org Git - python/commitdiff
bpo-30892: Fix _elementtree module initialization (#2647)
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 10 Jul 2017 20:28:02 +0000 (22:28 +0200)
committerGitHub <noreply@github.com>
Mon, 10 Jul 2017 20:28:02 +0000 (22:28 +0200)
Handle getattr(copy, 'deepcopy') error in _elementtree module
initialization.

Modules/_elementtree.c

index eaa9e873d22e4b5404ca8a383d234f7441e977a0..3537f19b1c7a9ce8a6665f5d604979ae2ceecfc6 100644 (file)
@@ -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;