aboutsummaryrefslogtreecommitdiffstats
path: root/mako/template.py
diff options
context:
space:
mode:
Diffstat (limited to 'mako/template.py')
-rw-r--r--mako/template.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/mako/template.py b/mako/template.py
index 4bf01e0..87f6898 100644
--- a/mako/template.py
+++ b/mako/template.py
@@ -352,7 +352,7 @@ def _compile_text(template, text, filename):
buffer_filters=template.buffer_filters,
imports=template.imports,
source_encoding=lexer.encoding,
- generate_unicode=not template.disable_unicode)
+ generate_magic_comment=template.disable_unicode)
cid = identifier
if isinstance(cid, unicode):
@@ -378,8 +378,12 @@ def _compile_module_file(template, text, filename, outputpath):
buffer_filters=template.buffer_filters,
imports=template.imports,
source_encoding=lexer.encoding,
- generate_unicode=not template.disable_unicode)
+ generate_magic_comment=True)
(dest, name) = tempfile.mkstemp()
+
+ if isinstance(source, unicode):
+ source = source.encode(lexer.encoding or 'ascii')
+
os.write(dest, source)
os.close(dest)
shutil.move(name, outputpath)