diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index 75bebc0b1668abd..26d6f2c84c89eed 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -714,7 +714,7 @@ def write(self, file_or_filename, *default_namespace* -- sets the default XML namespace (for "xmlns") - *method* -- either "xml" (default), "html, "text", or "c14n" + *method* -- either "xml" (default), "html" or "text" *short_empty_elements* -- controls the formatting of elements that contain no content. If True @@ -730,10 +730,7 @@ def write(self, file_or_filename, elif method not in _serialize: raise ValueError("unknown method %r" % method) if not encoding: - if method == "c14n": - encoding = "utf-8" - else: - encoding = "us-ascii" + encoding = "us-ascii" with _get_writer(file_or_filename, encoding) as (write, declared_encoding): if method == "xml" and (xml_declaration or (xml_declaration is None and @@ -749,10 +746,6 @@ def write(self, file_or_filename, serialize(write, self._root, qnames, namespaces, short_empty_elements=short_empty_elements) - def write_c14n(self, file): - # lxml.etree compatibility. use output method instead - return self.write(file, method="c14n") - # -------------------------------------------------------------------- # serialization support @@ -981,8 +974,6 @@ def _serialize_text(write, elem): "xml": _serialize_xml, "html": _serialize_html, "text": _serialize_text, -# this optional method is imported at the end of the module -# "c14n": _serialize_c14n, } @@ -1094,7 +1085,7 @@ def tostring(element, encoding=None, method=None, *, *element* is an Element instance, *encoding* is an optional output encoding defaulting to US-ASCII, *method* is an optional output which - can be one of "xml" (default), "html", "text" or "c14n", + can be one of "xml" (default), "html" or "text", *default_namespace* sets the default XML namespace (for "xmlns"). Returns an (optionally) encoded string containing the XML data.