Message126506
method xml.etree.ElementTree.tostring from module returns type bytes.
The documentation reads
"""Returns an encoded string containing the XML data."""
(from http://docs.python.org/py3k/library/xml.etree.elementtree.html#xml.etree.ElementTree.tostring as of 2011-01-18)
=======================================================
Here is a test program:
-------------------------------------------------------
#!/usr/bin/python
# created for python 3.1
import sys
print(sys.version) # for help verifying version tested
from xml.etree import ElementTree
sampleinput = """<?xml version="1.0"?><Hello></Hello>"""
xmlobj = ElementTree.fromstring(sampleinput)
type(xmlobj)
xmlstr = ElementTree.tostring(xmlobj,'utf-8')
print("xmlstr value is '", xmlstr, "'", sep="")
print("xmlstr type is '", type(xmlstr), "'", sep="")
-------------------------------------------------------
test program output:
-------------------------------------------------------
3.1.3 (r313:86834, Nov 27 2010, 18:30:53) [MSC v.1500 32 bit (Intel)]
xmlstr value is 'b'<Hello />''
xmlstr type is '<class 'bytes'>'
=======================================================
This cheap "fix" for this bug may be simply be a change in documentation.
However, a method called "tostring" really should return something nearer to the built-in str. |
|
Date |
User |
Action |
Args |
2011-01-19 00:12:30 | JTMoon79 | set | recipients:
+ JTMoon79, docs@python |
2011-01-19 00:12:29 | JTMoon79 | set | messageid: <1295395949.96.0.0409847573272.issue10942@psf.upfronthosting.co.za> |
2011-01-19 00:12:25 | JTMoon79 | link | issue10942 messages |
2011-01-19 00:12:25 | JTMoon79 | create | |
|