From c4e98a6a9bb73fb0bc1ea3d2d6fb63107416cddc Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Sun, 19 May 2013 09:24:43 -0700 Subject: Cleanup more old ET library leftovers --- Lib/test/test_xml_etree.py | 12 +----------- Lib/xml/etree/ElementTree.py | 11 ++++------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 2636da3..2222c86 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -240,7 +240,6 @@ class ElementTreeTest(unittest.TestCase): self.assertEqual(ET.XML, ET.fromstring) self.assertEqual(ET.PI, ET.ProcessingInstruction) - self.assertEqual(ET.XMLParser, ET.XMLTreeBuilder) def test_simpleops(self): # Basic method sanity checks. @@ -433,15 +432,6 @@ class ElementTreeTest(unittest.TestCase): ' \n' '') - parser = ET.XMLTreeBuilder() # 1.2 compatibility - parser.feed(data) - self.serialize_check(parser.close(), - '\n' - ' text\n' - ' texttail\n' - ' \n' - '') - target = ET.TreeBuilder() parser = ET.XMLParser(target=target) parser.feed(data) @@ -1407,7 +1397,7 @@ class BugsTest(unittest.TestCase): # Don't crash when using custom entities. ENTITIES = {'rsquo': '\u2019', 'lsquo': '\u2018'} - parser = ET.XMLTreeBuilder() + parser = ET.XMLParser() parser.entity.update(ENTITIES) parser.feed(""" diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index e0b4fd4..9ea0dc8 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -85,7 +85,7 @@ __all__ = [ "TreeBuilder", "VERSION", "XML", "XMLID", - "XMLParser", "XMLTreeBuilder", + "XMLParser", "register_namespace", ] @@ -1654,9 +1654,7 @@ try: # Element, SubElement, ParseError, TreeBuilder, XMLParser from _elementtree import * -except ImportError: - pass -else: + # Overwrite 'ElementTree.parse' to use the C XMLParser class ElementTree(ElementTree): __doc__ = ElementTree.__doc__ @@ -1681,11 +1679,10 @@ else: finally: if close_source: source.close() +except ImportError: + pass -# compatibility -XMLTreeBuilder = XMLParser - # workaround circular import. try: from ElementC14N import _serialize_c14n -- cgit v0.12