summaryrefslogtreecommitdiffstats
path: root/Modules/_elementtree.c
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2013-01-10 14:27:53 (GMT)
committerEli Bendersky <eliben@gmail.com>2013-01-10 14:27:53 (GMT)
commite6174ca85e293039c464e06bf3a656300347b562 (patch)
treef78ed07b81f69ea07374c3199bdf6556683704eb /Modules/_elementtree.c
parent458c0d5a776746267f432e6860050af367fb5431 (diff)
downloadcpython-e6174ca85e293039c464e06bf3a656300347b562.zip
cpython-e6174ca85e293039c464e06bf3a656300347b562.tar.gz
cpython-e6174ca85e293039c464e06bf3a656300347b562.tar.bz2
Issue #16913: Fix Element.itertext()'s handling of text with XML entities.
Patch by Serhiy Storchaka
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r--Modules/_elementtree.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 4b53037..2129fc2 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -2017,7 +2017,9 @@ elementiter_next(ElementIterObject *it)
PyObject_RichCompareBool(it->root_element->tag,
it->sought_tag, Py_EQ) == 1) {
if (it->gettext) {
- PyObject *text = JOIN_OBJ(it->root_element->text);
+ PyObject *text = element_get_text(it->root_element);
+ if (!text)
+ return NULL;
if (PyObject_IsTrue(text)) {
Py_INCREF(text);
return text;
@@ -2047,7 +2049,9 @@ elementiter_next(ElementIterObject *it)
}
if (it->gettext) {
- PyObject *text = JOIN_OBJ(child->text);
+ PyObject *text = element_get_text(child);
+ if (!text)
+ return NULL;
if (PyObject_IsTrue(text)) {
Py_INCREF(text);
return text;
@@ -2062,8 +2066,15 @@ elementiter_next(ElementIterObject *it)
continue;
}
else {
- PyObject *tail = it->gettext ? JOIN_OBJ(cur_parent->tail) : Py_None;
+ PyObject *tail;
ParentLocator *next = it->parent_stack->next;
+ if (it->gettext) {
+ tail = element_get_tail(cur_parent);
+ if (!tail)
+ return NULL;
+ }
+ else
+ tail = Py_None;
Py_XDECREF(it->parent_stack->parent);
PyObject_Free(it->parent_stack);
it->parent_stack = next;