diff options
-rw-r--r-- | Lib/test/test_xml_etree.py | 3 | ||||
-rw-r--r-- | Modules/_elementtree.c | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 59a8508..b4edd74 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1773,6 +1773,9 @@ class ElementFindTest(unittest.TestCase): self.assertIsNone(e.findtext('tog')) self.assertEqual(e.findtext('tog', 'default'), 'default') + # Issue #16922 + self.assertEqual(ET.XML('<tag><empty /></tag>').findtext('empty'), '') + def test_findall(self): e = ET.XML(SAMPLE_XML) e[2] = ET.XML(SAMPLE_SECTION) diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index 274c65e..49441cc 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -1129,7 +1129,7 @@ element_findtext(ElementObject *self, PyObject *args, PyObject *kwds) PyObject* text = element_get_text(item); if (text == Py_None) - return PyBytes_FromString(""); + return PyUnicode_New(0, 0); Py_XINCREF(text); return text; } |