summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-08-08 19:48:29 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-08-08 19:48:29 (GMT)
commitc17f17294fb31967b52b5b7039d7587e0f82c3bb (patch)
tree8d7021b079f787e45382391cd3327a0127f2923d /Doc/library
parent1a0a737b131b5c54ba32a8dc707db39b4ce03674 (diff)
downloadcpython-c17f17294fb31967b52b5b7039d7587e0f82c3bb.zip
cpython-c17f17294fb31967b52b5b7039d7587e0f82c3bb.tar.gz
cpython-c17f17294fb31967b52b5b7039d7587e0f82c3bb.tar.bz2
Issue #8047: Fix the xml.etree serializer to return bytes by default.
Use ``encoding="unicode"`` to generate a Unicode string.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/xml.etree.elementtree.rst22
1 files changed, 13 insertions, 9 deletions
diff --git a/Doc/library/xml.etree.elementtree.rst b/Doc/library/xml.etree.elementtree.rst
index 892a59a..32057d4 100644
--- a/Doc/library/xml.etree.elementtree.rst
+++ b/Doc/library/xml.etree.elementtree.rst
@@ -148,20 +148,22 @@ Functions
arguments. Returns an element instance.
-.. function:: tostring(element, encoding=None, method="xml")
+.. function:: tostring(element, encoding="us-ascii", method="xml")
Generates a string representation of an XML element, including all
subelements. *element* is an :class:`Element` instance. *encoding* [1]_ is
- the output encoding (default is None). *method* is either ``"xml"``,
+ the output encoding (default is US-ASCII). Use ``encoding="unicode"`` to
+ generate a Unicode string. *method* is either ``"xml"``,
``"html"`` or ``"text"`` (default is ``"xml"``). Returns an (optionally)
encoded string containing the XML data.
-.. function:: tostringlist(element, encoding=None, method="xml")
+.. function:: tostringlist(element, encoding="us-ascii", method="xml")
Generates a string representation of an XML element, including all
subelements. *element* is an :class:`Element` instance. *encoding* [1]_ is
- the output encoding (default is None). *method* is either ``"xml"``,
+ the output encoding (default is US-ASCII). Use ``encoding="unicode"`` to
+ generate a Unicode string. *method* is either ``"xml"``,
``"html"`` or ``"text"`` (default is ``"xml"``). Returns a list of
(optionally) encoded strings containing the XML data. It does not guarantee
any specific sequence, except that ``"".join(tostringlist(element)) ==
@@ -430,6 +432,7 @@ ElementTree Objects
.. method:: getroot()
+
Returns the root element for this tree.
@@ -457,15 +460,16 @@ ElementTree Objects
root element.
- .. method:: write(file, encoding=None, xml_declaration=None, method="xml")
+ .. method:: write(file, encoding="us-ascii", xml_declaration=None, method="xml")
Writes the element tree to a file, as XML. *file* is a file name, or a
file object opened for writing. *encoding* [1]_ is the output encoding
- (default is None). *xml_declaration* controls if an XML declaration
+ (default is US-ASCII). Use ``encoding="unicode"`` to write a Unicode string.
+ *xml_declaration* controls if an XML declaration
should be added to the file. Use False for never, True for always, None
- for only if not US-ASCII or UTF-8 (default is None). *method* is either
- ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``). Returns an
- (optionally) encoded string.
+ for only if not US-ASCII or UTF-8 or Unicode (default is None). *method* is
+ either ``"xml"``, ``"html"`` or ``"text"`` (default is ``"xml"``).
+ Returns an (optionally) encoded string.
This is the XML file that is going to be manipulated::