summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/xml
diff options
context:
space:
mode:
authorarcadia-devtools <[email protected]>2022-03-18 09:10:23 +0300
committerarcadia-devtools <[email protected]>2022-03-18 09:10:23 +0300
commitfef2b3a8ed5955b63c71e8e541a5acf2e393925a (patch)
treee55d2882d5c2c71561a0aa89158ec174d81f92fd /contrib/tools/python3/src/Lib/xml
parent2acc0fc3cdc40434ea286f2fac62386e3fd9c19d (diff)
intermediate changes
ref:102662f6c42fba80d7bfd4a328124cbb4294be48
Diffstat (limited to 'contrib/tools/python3/src/Lib/xml')
-rw-r--r--contrib/tools/python3/src/Lib/xml/etree/ElementTree.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/contrib/tools/python3/src/Lib/xml/etree/ElementTree.py b/contrib/tools/python3/src/Lib/xml/etree/ElementTree.py
index fde303c875c..dae2251d859 100644
--- a/contrib/tools/python3/src/Lib/xml/etree/ElementTree.py
+++ b/contrib/tools/python3/src/Lib/xml/etree/ElementTree.py
@@ -1248,8 +1248,14 @@ def iterparse(source, events=None, parser=None):
# Use the internal, undocumented _parser argument for now; When the
# parser argument of iterparse is removed, this can be killed.
pullparser = XMLPullParser(events=events, _parser=parser)
- def iterator():
+
+ def iterator(source):
+ close_source = False
try:
+ if not hasattr(source, "read"):
+ source = open(source, "rb")
+ close_source = True
+ yield None
while True:
yield from pullparser.read_events()
# load event buffer
@@ -1265,16 +1271,12 @@ def iterparse(source, events=None, parser=None):
source.close()
class IterParseIterator(collections.abc.Iterator):
- __next__ = iterator().__next__
+ __next__ = iterator(source).__next__
it = IterParseIterator()
it.root = None
del iterator, IterParseIterator
- close_source = False
- if not hasattr(source, "read"):
- source = open(source, "rb")
- close_source = True
-
+ next(it)
return it