Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-118318: Remove outdated c14n references from ElementTree #118319

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 4 additions & 13 deletions Lib/xml/etree/ElementTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,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 (default)
Expand All @@ -710,10 +710,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
Expand All @@ -729,10 +726,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

Expand Down Expand Up @@ -961,8 +954,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,
}


Expand Down Expand Up @@ -1074,8 +1065,8 @@ 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", *default_namespace*
sets the default XML namespace (for "xmlns").
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.

Expand Down