From ddcccfeaa952d2e1e24ceac94e5d66c73b57c01b Mon Sep 17 00:00:00 2001 From: Alexander Artemenko Date: Wed, 23 Mar 2011 11:14:25 +0300 Subject: [PATCH] Switch to 'C' locale during page rendering. Don't know why, but without it Jinja fails with UnicodeDecode error. --- pelican/writers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pelican/writers.py b/pelican/writers.py index 2c135270..afc37648 100644 --- a/pelican/writers.py +++ b/pelican/writers.py @@ -90,7 +90,12 @@ class Writer(object): def _write_file(template, localcontext, output_path, name): """Render the template write the file.""" - output = template.render(localcontext) + old_locale = locale.setlocale(locale.LC_ALL) + locale.setlocale(locale.LC_ALL, 'C') + try: + output = template.render(localcontext) + finally: + locale.setlocale(locale.LC_ALL, old_locale) filename = os.sep.join((output_path, name)) try: os.makedirs(os.path.dirname(filename))