Commit b09b1674 authored by Eli Bendersky's avatar Eli Bendersky

Issue #16922: fixed findtext() to return empty Unicode string instead of empty...

Issue #16922: fixed findtext() to return empty Unicode string instead of empty bytes object when there's no text.

Patch by Serhiy Storchaka.
parent ce1519d2
......@@ -352,6 +352,8 @@ def find():
'subtext'
>>> ET.ElementTree(elem).findtext("section/tag")
'subtext'
>>> ET.XML('<root><empty /></root>').findtext('empty')
''
>>> summarize_list(elem.findall("."))
['body']
>>> summarize_list(elem.findall("tag"))
......
......@@ -840,7 +840,7 @@ element_findtext(ElementObject* self, PyObject* args)
PyObject* text = element_get_text(item);
if (text == Py_None)
return PyBytes_FromString("");
return PyUnicode_FromString("");
Py_XINCREF(text);
return text;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment