comparison mercurial/templater.py @ 14168:135e244776f0

prevent transient leaks of file handle by using new helper functions These leaks may occur in environments that don't employ a reference counting GC, i.e. PyPy. This implies: - changing opener(...).read() calls to opener.read(...) - changing opener(...).write() calls to opener.write(...) - changing open(...).read(...) to util.readfile(...) - changing open(...).write(...) to util.writefile(...)
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Mon, 02 May 2011 10:11:18 +0200
parents e798e430c5e5
children ab545a15d807
comparison
equal deleted inserted replaced
14167:0e4753807c93 14168:135e244776f0
309 309
310 def load(self, t): 310 def load(self, t):
311 '''Get the template for the given template name. Use a local cache.''' 311 '''Get the template for the given template name. Use a local cache.'''
312 if not t in self.cache: 312 if not t in self.cache:
313 try: 313 try:
314 self.cache[t] = open(self.map[t][1]).read() 314 self.cache[t] = util.readfile(self.map[t][1])
315 except KeyError, inst: 315 except KeyError, inst:
316 raise util.Abort(_('"%s" not in template map') % inst.args[0]) 316 raise util.Abort(_('"%s" not in template map') % inst.args[0])
317 except IOError, inst: 317 except IOError, inst:
318 raise IOError(inst.args[0], _('template file %s: %s') % 318 raise IOError(inst.args[0], _('template file %s: %s') %
319 (self.map[t][1], inst.args[1])) 319 (self.map[t][1], inst.args[1]))