← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~alvarocs/launchpad:upgrade-defusedxml into launchpad:master

 

Alvaro Crespo Serrano has proposed merging ~alvarocs/launchpad:upgrade-defusedxml into launchpad:master.

Commit message:
Update defusedxml to 0.8.0rc2

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~alvarocs/launchpad/+git/launchpad/+merge/477755

Upgraded to the latest available release candidate version 0.8.0rc2, compatible with Python 3.12.
 - All tests related to the use of defusedxml passed after the upgrade of the package.
 - Updated defusedxml.cElementTree to defusedxml.ElementTree as it will be deprecated.

To be merged after the update on lp-source-dependencies is merged - https://code.launchpad.net/~alvarocs/lp-source-dependencies/+git/lp-source-dependencies/+merge/477756
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~alvarocs/launchpad:upgrade-defusedxml into launchpad:master.
diff --git a/lib/lp/bugs/doc/bug-export.rst b/lib/lp/bugs/doc/bug-export.rst
index 56063b1..08d7b93 100644
--- a/lib/lp/bugs/doc/bug-export.rst
+++ b/lib/lp/bugs/doc/bug-export.rst
@@ -22,9 +22,9 @@ setup:
     >>> import io
     >>> import sys
     >>> try:
-    ...     import xml.etree.cElementTree as ET
+    ...     import xml.etree.ElementTree as ET
     ... except ImportError:
-    ...     import cElementTree as ET
+    ...     import ElementTree as ET
     ...
     >>> from zope.component import getUtility
     >>> from lp.bugs.interfaces.bug import IBugSet
diff --git a/lib/lp/bugs/scripts/bugimport.py b/lib/lp/bugs/scripts/bugimport.py
index 4618c72..3d6b86e 100644
--- a/lib/lp/bugs/scripts/bugimport.py
+++ b/lib/lp/bugs/scripts/bugimport.py
@@ -21,7 +21,7 @@ import time
 from datetime import datetime, timezone
 
 import six
-from defusedxml import cElementTree
+from defusedxml import ElementTree
 from storm.store import Store
 from zope.component import getUtility
 from zope.contenttype import guess_content_type
@@ -237,7 +237,7 @@ class BugImporter:
 
     def importBugs(self, ztm):
         """Import bugs from a file."""
-        tree = cElementTree.parse(self.bugs_filename, forbid_dtd=True)
+        tree = ElementTree.parse(self.bugs_filename, forbid_dtd=True)
         root = tree.getroot()
         assert root.tag == "{%s}launchpad-bugs" % BUGS_XMLNS, (
             "Root element is wrong: %s" % root.tag
diff --git a/lib/lp/bugs/scripts/cveimport.py b/lib/lp/bugs/scripts/cveimport.py
index 464fe58..a065868 100644
--- a/lib/lp/bugs/scripts/cveimport.py
+++ b/lib/lp/bugs/scripts/cveimport.py
@@ -9,7 +9,7 @@ import gzip
 import io
 import time
 
-import defusedxml.cElementTree as cElementTree
+import defusedxml.ElementTree as ElementTree
 import requests
 import six
 from zope.component import getUtility
@@ -256,7 +256,7 @@ class CVEUpdater(LaunchpadCronScript):
 
         :param cve_xml: The CVE XML as a string.
         """
-        dom = cElementTree.fromstring(cve_xml, forbid_dtd=True)
+        dom = ElementTree.fromstring(cve_xml, forbid_dtd=True)
         items = dom.findall(CVEDB_NS + "item")
         if len(items) == 0:
             raise LaunchpadScriptFailure("No CVEs found in XML file.")
diff --git a/lib/lp/bugs/scripts/tests/test_bugimport.py b/lib/lp/bugs/scripts/tests/test_bugimport.py
index f091afb..c720fa0 100644
--- a/lib/lp/bugs/scripts/tests/test_bugimport.py
+++ b/lib/lp/bugs/scripts/tests/test_bugimport.py
@@ -5,7 +5,7 @@ import os
 import re
 from datetime import timezone
 
-import defusedxml.cElementTree as ET
+import defusedxml.ElementTree as ET
 import transaction
 from testtools.content import text_content
 from zope.component import getUtility
diff --git a/lib/lp/translations/utilities/xpi_header.py b/lib/lp/translations/utilities/xpi_header.py
index 0e4ee58..04a5ab8 100644
--- a/lib/lp/translations/utilities/xpi_header.py
+++ b/lib/lp/translations/utilities/xpi_header.py
@@ -8,7 +8,7 @@ __all__ = [
 import io
 from email.utils import parseaddr
 
-import defusedxml.cElementTree as cElementTree
+import defusedxml.ElementTree as ElementTree
 from zope.interface import implementer
 
 from lp.translations.interfaces.translationcommonformat import (
@@ -61,13 +61,13 @@ class XpiHeader:
         """See `ITranslationHeaderData`."""
         last_name, last_email = None, None
         contributor_tag = "{http://www.mozilla.org/2004/em-rdf#}contributor";
-        # Both cElementTree and elementtree fail when trying to parse
+        # Both ElementTree and elementtree fail when trying to parse
         # proper unicode strings.  Use our raw input instead.
         try:
             raw_content = self._raw_content
             if not isinstance(raw_content, bytes):
                 raw_content = raw_content.encode()
-            parse = cElementTree.iterparse(
+            parse = ElementTree.iterparse(
                 io.BytesIO(raw_content), forbid_dtd=True
             )
             for _, elem in parse:
diff --git a/requirements/launchpad.txt b/requirements/launchpad.txt
index f7d44a8..c4f985a 100644
--- a/requirements/launchpad.txt
+++ b/requirements/launchpad.txt
@@ -38,7 +38,7 @@ Cython==0.29.17
 d2to1==0.2.12
 debtcollector==1.22.0
 decorator==5.1.1
-defusedxml==0.6.0
+defusedxml==0.8.0rc2
 difftacular==0.1
 distro==1.4.0
 dkimpy==1.1.8