summaryrefslogtreecommitdiffstats
path: root/Lib/xml/etree/ElementInclude.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/xml/etree/ElementInclude.py')
-rw-r--r--Lib/xml/etree/ElementInclude.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/xml/etree/ElementInclude.py b/Lib/xml/etree/ElementInclude.py
index 84fd754..7e29119 100644
--- a/Lib/xml/etree/ElementInclude.py
+++ b/Lib/xml/etree/ElementInclude.py
@@ -75,14 +75,13 @@ class FatalIncludeError(SyntaxError):
# @throws IOError If the loader fails to load the resource.
def default_loader(href, parse, encoding=None):
- file = open(href)
- if parse == "xml":
- data = ElementTree.parse(file).getroot()
- else:
- data = file.read()
- if encoding:
- data = data.decode(encoding)
- file.close()
+ with open(href) as file:
+ if parse == "xml":
+ data = ElementTree.parse(file).getroot()
+ else:
+ data = file.read()
+ if encoding:
+ data = data.decode(encoding)
return data
##