module have been removed. They were deprecated in Python 3.2.
Use ``iter(x)`` or ``list(x)`` instead of ``x.getchildren()`` and
``x.iter()`` or ``list(x.iter())`` instead of ``x.getiterator()``.
- The ``xml.etree.cElementTree`` module has been removed,
- use the :mod:`xml.etree.ElementTree` module instead.
- Since Python 3.3 the ``xml.etree.cElementTree`` module has been deprecated,
- the ``xml.etree.ElementTree`` module uses a fast implementation whenever
- available.
(Contributed by Serhiy Storchaka in :issue:`36543`.)
* The old :mod:`plistlib` API has been removed, it was deprecated since Python
cET = import_fresh_module('xml.etree.ElementTree',
fresh=['_elementtree'])
+cET_alias = import_fresh_module('xml.etree.cElementTree',
+ fresh=['_elementtree', 'xml.etree'],
+ deprecated=True)
@unittest.skipUnless(cET, 'requires _elementtree')
support.gc_collect()
+@unittest.skipUnless(cET, 'requires _elementtree')
+class TestAliasWorking(unittest.TestCase):
+ # Test that the cET alias module is alive
+ def test_alias_working(self):
+ e = cET_alias.Element('foo')
+ self.assertEqual(e.tag, 'foo')
+
+
@unittest.skipUnless(cET, 'requires _elementtree')
@support.cpython_only
class TestAcceleratorImported(unittest.TestCase):
# SubElement is a function so it retains _elementtree as its module.
self.assertEqual(cET.SubElement.__module__, '_elementtree')
+ def test_correct_import_cET_alias(self):
+ self.assertEqual(cET_alias.SubElement.__module__, '_elementtree')
+
def test_parser_comes_from_C(self):
# The type of methods defined in Python code is types.FunctionType,
# while the type of methods defined inside _elementtree is
# Run the tests specific to the C implementation
support.run_unittest(
MiscTests,
+ TestAliasWorking,
TestAcceleratorImported,
SizeofTest,
)