bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146)



The C accelerated _elementtree module now initializes hash randomization
salt from _Py_HashSecret instead of libexpat's default CPRNG.

Signed-off-by: Christian Heimes <christian@python.org>



https://bugs.python.org/issue34623
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 02781d5..bba6873 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -3272,6 +3272,11 @@
         PyErr_NoMemory();
         return -1;
     }
+    /* expat < 2.1.0 has no XML_SetHashSalt() */
+    if (EXPAT(SetHashSalt) != NULL) {
+        EXPAT(SetHashSalt)(self->parser,
+                           (unsigned long)_Py_HashSecret.expat.hashsalt);
+    }
 
     if (target) {
         Py_INCREF(target);