summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Gedminas <marius@gedmin.as>2013-02-07 23:04:52 +0000
committerMarius Gedminas <marius@gedmin.as>2013-02-07 23:04:52 +0000
commit040631594cdcf3edb55e35e80bb0b6ef1ba66921 (patch)
treed14a1113560de69a580f481b540beca2a4425914
parent40a8c1d0df04e5a970d8c3c4a56540d0f32d4825 (diff)
downloadzope-tal-040631594cdcf3edb55e35e80bb0b6ef1ba66921.tar.gz
Towards Py3K: xml.parsers.expat wants byte strings (part 2)
Also avoid ResourceWarning by explicitly closing the file.
-rw-r--r--src/zope/tal/xmlparser.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/zope/tal/xmlparser.py b/src/zope/tal/xmlparser.py
index d991e48..9081d37 100644
--- a/src/zope/tal/xmlparser.py
+++ b/src/zope/tal/xmlparser.py
@@ -82,7 +82,8 @@ class XMLParser(object):
return expat.ParserCreate(encoding, ' ')
def parseFile(self, filename):
- self.parseStream(open(filename))
+ with open(filename, 'rb') as f:
+ self.parseStream(f)
def parseString(self, s):
if isinstance(s, unicode):