summaryrefslogtreecommitdiffstats
path: root/Lib/xml/etree
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-08-23 21:04:30 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2013-08-23 21:04:30 (GMT)
commit0acbcb5bbeec87e3a8fae872a0368a4e297a8e8a (patch)
treee6ba262e023faca5105d333a995012ca0e53aa00 /Lib/xml/etree
parent892584e091bb9121777f971e0bb700da11cab235 (diff)
downloadcpython-0acbcb5bbeec87e3a8fae872a0368a4e297a8e8a.zip
cpython-0acbcb5bbeec87e3a8fae872a0368a4e297a8e8a.tar.gz
cpython-0acbcb5bbeec87e3a8fae872a0368a4e297a8e8a.tar.bz2
Issue #17741: use composition, rather than inheritance, for xml.etree.iterparse's result class.
Patch by Stefan Behnel.
Diffstat (limited to 'Lib/xml/etree')
-rw-r--r--Lib/xml/etree/ElementTree.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index bb34bb3..291579b 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -1265,27 +1265,29 @@ class IncrementalParser:
self.root = self._root
-class _IterParseIterator(IncrementalParser):
+class _IterParseIterator:
def __init__(self, source, events, parser, close_source=False):
- IncrementalParser.__init__(self, events, parser)
+ self._parser = IncrementalParser(events, parser)
self._file = source
self._close_file = close_source
+ self.root = None
def __next__(self):
while 1:
- for event in self.events():
+ for event in self._parser.events():
return event
- if self._parser is None:
+ if self._parser._parser is None:
+ self.root = self._parser.root
if self._close_file:
self._file.close()
raise StopIteration
# load event buffer
data = self._file.read(16384)
if data:
- self.data_received(data)
+ self._parser.data_received(data)
else:
- self.eof_received()
+ self._parser.eof_received()
def __iter__(self):
return self