Closed
Description
The function ET.tostring() does not escape carriage return (\r) when serializing a XML tree. This eventually causes the \r to disappear when re-parsing the output of ET.tostring().
>>> import xml.etree.ElementTree as ET
>>> xmlstr = "<elem>x </elem>"
>>> ET.tostring(ET.fromstring(xmlstr))
b'<foo>x\r\n</foo>'
>>> ET.tostring(ET.fromstring(_))
b'<foo>x\n</foo>'This happens with Python 2.7.12 and Python 3.8.1.
I also tried lxml and the C++ libraries TinyXml and Xerces whith this problem and all of them replaced \r with or '
, making the tostring() function reversible.

