Index: lib/mako/exceptions.py =================================================================== --- lib/mako/exceptions.py (revision 258) +++ lib/mako/exceptions.py (working copy) @@ -6,7 +6,7 @@ """exception classes""" -import traceback, sys, re +import codecs, parser, re, sys, traceback class MakoException(Exception): pass @@ -68,7 +68,12 @@ if self.error is None: self.error = t if isinstance(self.error, CompileException) or isinstance(self.error, SyntaxException): - self.source = file(self.error.filename).read() + source_file = file(self.error.filename) + self.source = source_file.read() + self.source_encoding = _parse_encoding(source_file) + if self.source_encoding is None: + self.source_encoding = sys.getdefaultencoding() + source_file.close() self.lineno = self.error.lineno self._has_source = True self.reverse_records = [r for r in self.records] @@ -188,7 +193,7 @@