Serhiy Storchaka added the comment:
Can you please provide an example of data for which the tostring method fails?
I can't reproduce this on simple data.
import xml.etree.ElementTree as ET
ET.tostring(ET.XML('rootbq/bwerty/root'), method='text',
encoding='unicode')
'qwerty'
--
Serhiy Storchaka added the comment:
I found such example. It happens when the data contains XML entity.
ET.tostring(ET.XML('rootaamp;/root'), method='text',
encoding='unicode')
Traceback (most recent call last):
File stdin, line 1, in module
File
Frank added the comment:
It happens whenever the method is called, regardless of input. I'm using HTML
that has been tidied first with HTML entities (if any) converted to unicode
values.
--
___
Python tracker rep...@bugs.python.org
Frank added the comment:
Scratch that, it happens whenever there are XML entities (lt;, quot; and
friends) that are appearing the text as you pointed out.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16913
Serhiy Storchaka added the comment:
Here is a patch for 3.3+. 2.7 and 3.2 are not affected.
--
keywords: +patch
stage: needs patch - patch review
versions: +Python 3.4
Added file: http://bugs.python.org/file28666/etree_itertext.patch
___
Python
Roundup Robot added the comment:
New changeset d965ff47cf94 by Eli Bendersky in branch '3.3':
Issue #16913: Fix Element.itertext()'s handling of text with XML entities.
http://hg.python.org/cpython/rev/d965ff47cf94
New changeset 9ab8632e7213 by Eli Bendersky in branch 'default':
Issue #16913:
Eli Bendersky added the comment:
Fixed. Thanks.
--
resolution: - fixed
stage: patch review - committed/rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16913
___
New submission from Frank:
Since upgrading to python 3.3 the tostring method fails when the output method
is requested as text. Code like this:
with open(fp, mode='rt') as f:
data = f.read()
tree, idmap = ET.XMLID(data)
print(ET.tostring(tree, method='text', encoding='unicode'))
Generates
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
keywords: +3.3regression
nosy: +eli.bendersky, ezio.melotti
stage: - needs patch
type: - behavior
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16913