summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2012-04-02 06:23:14 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2012-04-02 19:24:19 -0700
commita0b4e4fe2d01a8871ccd371a00155b8f475de44b (patch)
tree77e82d7c225d06c51a8651520cdbffa5e2c740eb
parente0f1403939c4326ac99aff9ae84d375f76fbe770 (diff)
downloadpystache-a0b4e4fe2d01a8871ccd371a00155b8f475de44b.tar.gz
Eliminated one use of the with keyword for Python 2.4 support.
-rw-r--r--pystache/loader.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/pystache/loader.py b/pystache/loader.py
index 3f049a4..bcba71b 100644
--- a/pystache/loader.py
+++ b/pystache/loader.py
@@ -5,8 +5,6 @@ This module provides a Loader class for locating and reading templates.
"""
-from __future__ import with_statement
-
import os
import sys
@@ -108,8 +106,12 @@ class Loader(object):
Read the template at the given path, and return it as a unicode string.
"""
- with open(path, 'r') as f:
+ # We avoid use of the with keyword for Python 2.4 support.
+ f = open(path, 'r')
+ try:
text = f.read()
+ finally:
+ f.close()
if encoding is None:
encoding = self.file_encoding