diff --git a/pystache/common.py b/pystache/common.py index fb266dd..62bd2c4 100644 --- a/pystache/common.py +++ b/pystache/common.py @@ -45,10 +45,15 @@ def read(path): # read() method returns byte strings (strings of type `str` in Python 2), # whereas in Python 3, the file object returns unicode strings (strings # of type `str` in Python 3). - f = open(path, 'rb') + if version_info < (3, ): + f = open(path, 'rbU') + else: + f = open(path, 'r') # We avoid use of the with keyword for Python 2.4 support. try: - return f.read() + if version_info < (3, ): + return f.read() + return f.read().encode('utf_8') finally: f.close()