diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-21 09:09:48 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-21 09:09:48 (GMT) |
commit | 66c08d90f6d7e5889a19891a0ef994354b14f172 (patch) | |
tree | 53ef527e4ce8cba37f0f0d753f666cafdbfd0cdf /Lib/xml | |
parent | 0744641668ebf975fa41707ed7eb467c9cac2f67 (diff) | |
download | cpython-66c08d90f6d7e5889a19891a0ef994354b14f172.zip cpython-66c08d90f6d7e5889a19891a0ef994354b14f172.tar.gz cpython-66c08d90f6d7e5889a19891a0ef994354b14f172.tar.bz2 |
Issue #25902: Fixed various refcount issues in ElementTree iteration.
Diffstat (limited to 'Lib/xml')
-rw-r--r-- | Lib/xml/etree/ElementTree.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index 62b5d3a..b4e110d 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -428,12 +428,14 @@ class Element: tag = self.tag if not isinstance(tag, str) and tag is not None: return - if self.text: - yield self.text + t = self.text + if t: + yield t for e in self: yield from e.itertext() - if e.tail: - yield e.tail + t = e.tail + if t: + yield t def SubElement(parent, tag, attrib={}, **extra): |