From 794fea64ed11b6c2b2604c3a0daa374c885f09d6 Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Tue, 10 Feb 2015 20:45:35 +0100 Subject: Use minidom factory methods in xml coverage generator The exportToXML was creating an minidom.Element using it's constructor, which is forbidden in the documentation: > Applications should not instantiate the classes themselves; they should use the creator functions available on the Document object. http://docs.python.org/library/xml.dom.minidom.html Since python 3.4 this method no longer works (private interface change) thus the xml coverage generation was broken. Fix by calling the recommended method Document.createElement. See bug: http://bugs.python.org/issue15290 Signed-off-by: Kevin Rocard --- tools/coverage/coverage.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/coverage/coverage.py b/tools/coverage/coverage.py index 0b9dd4c..1df02ae 100755 --- a/tools/coverage/coverage.py +++ b/tools/coverage/coverage.py @@ -204,14 +204,14 @@ class Element(): str(dumpedDescription) for dumpedDescription in self._dumpDescription(withCoverage, withNbUse)) - def exportToXML(self, domElement=None): + def exportToXML(self, document, domElement=None): if domElement == None: - domElement = xml.dom.minidom.Element(self.tag) + domElement = document.createElement(self.tag) self._XMLaddAttributes(domElement) for child in self.children : - domElement.appendChild(child.exportToXML()) + domElement.appendChild(child.exportToXML(document)) return domElement @@ -877,10 +877,10 @@ class Root(Element): def exportToXML(self): """Export tree to an xml document""" impl = xml.dom.minidom.getDOMImplementation() - newdoc = impl.createDocument(namespaceURI=None, qualifiedName=self.tag, doctype=None) - super().exportToXML(newdoc.documentElement) + document = impl.createDocument(namespaceURI=None, qualifiedName=self.tag, doctype=None) + super().exportToXML(document, document.documentElement) - return newdoc + return document # ============================ # Command line argument parser -- cgit v1.1