From: Meng Zhuo Date: Sun, 2 Mar 2014 14:20:49 +0000 (+0800) Subject: update Template Loader with 'with' statment X-Git-Tag: v4.0.0b1~110^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41a8f1a393a56eff00e60ab6b552fdbc38c64486;p=thirdparty%2Ftornado.git update Template Loader with 'with' statment --- diff --git a/tornado/template.py b/tornado/template.py index db5a528dc..94127e79f 100644 --- a/tornado/template.py +++ b/tornado/template.py @@ -367,10 +367,9 @@ class Loader(BaseLoader): def _create_template(self, name): path = os.path.join(self.root, name) - f = open(path, "rb") - template = Template(f.read(), name=name, loader=self) - f.close() - return template + with open(path, "rb") as f: + template = Template(f.read(), name=name, loader=self) + return template class DictLoader(BaseLoader):