Open christianspecht opened 11 years ago
I suppose that I know now why this happens:
March means März in German (notice the ä) and it's the only German month that has an umlaut in its name.
It's pretty clear if you read the error message (it says that a UnicodeDecodeError
happened), but I didn't see the connection at the time.
I found out about this because I'm trying to translate the output of bf.config.blog.archive_links
right now.
I wasn't able to come up with a better solution, so I just replace the German month names with the English ones:
% for link, name, num_posts in bf.config.blog.archive_links:
<%
if name.startswith('Januar'):
month=name.replace('Januar','January')
elif name.startswith('Februar'):
month=name.replace('Februar','February')
[...]
else:
month=name
%>
<li><a href="${bf.util.site_path_helper(bf.config.blog.path,link)}/1">${month} (${num_posts})</a></li>
% endfor
Basically, this works, but as soon as I insert the lines for März (March), Blogofile crashes with the error below.
The last line says mako.exceptions.CompileException: Unicode decode operation of encoding 'utf-8' failed in file '_templates/site.mako' at line: 0 char: 0
, so I guess it's actually a bug in Mako, not in Blogofile?
ERROR:blogofile:Fatal build error occured, calling bf.config.build_exception()
Traceback (most recent call last):
File "C:\Program Files (x86)\Python27\Scripts\blogofile-script.py", line 8, in
<module>
load_entry_point('blogofile==0.8b1', 'console_scripts', 'blogofile')()
File "C:\Program Files (x86)\Python27\lib\site-packages\blogofile-0.8b1-py2.7.
egg\blogofile\main.py", line 58, in main
args.func(args)
File "C:\Program Files (x86)\Python27\lib\site-packages\blogofile-0.8b1-py2.7.
egg\blogofile\main.py", line 388, in do_build
writer.write_site()
File "C:\Program Files (x86)\Python27\lib\site-packages\blogofile-0.8b1-py2.7.
egg\blogofile\writer.py", line 49, in write_site
self.__run_controllers()
File "C:\Program Files (x86)\Python27\lib\site-packages\blogofile-0.8b1-py2.7.
egg\blogofile\writer.py", line 162, in __run_controllers
controller.run_all(namespaces)
File "C:\Program Files (x86)\Python27\lib\site-packages\blogofile-0.8b1-py2.7.
egg\blogofile\controller.py", line 229, in run_all
c.mod.run()
File "C:\Program Files (x86)\Python27\lib\site-packages\blogofile_blog-0.8b1-p
y2.7.egg\blogofile_blog\site_src\_controllers\blog\__init__.py", line 80, in run
permapage.run()
File "C:\Program Files (x86)\Python27\lib\site-packages\blogofile_blog-0.8b1-p
y2.7.egg\blogofile_blog\site_src\_controllers\blog\permapage.py", line 12, in ru
n
write_permapages()
File "C:\Program Files (x86)\Python27\lib\site-packages\blogofile_blog-0.8b1-p
y2.7.egg\blogofile_blog\site_src\_controllers\blog\permapage.py", line 38, in wr
ite_permapages
"permapage.mako", bf.util.path_join(path, "index.html"), env)
File "C:\Program Files (x86)\Python27\lib\site-packages\blogofile-0.8b1-py2.7.
egg\blogofile\plugin.py", line 160, in materialize_template
lookup=self.template_lookup, caller=self.module)
File "C:\Program Files (x86)\Python27\lib\site-packages\blogofile-0.8b1-py2.7.
egg\blogofile\template.py", line 388, in materialize_template
template.render(location)
File "C:\Program Files (x86)\Python27\lib\site-packages\blogofile-0.8b1-py2.7.
egg\blogofile\template.py", line 155, in render
bf.config.site.base_template))
File "C:\Program Files (x86)\Python27\lib\site-packages\mako-0.7.2-py2.7.egg\m
ako\lookup.py", line 240, in get_template
return self._load(srcfile, uri)
File "C:\Program Files (x86)\Python27\lib\site-packages\mako-0.7.2-py2.7.egg\m
ako\lookup.py", line 306, in _load
**self.template_args)
File "C:\Program Files (x86)\Python27\lib\site-packages\mako-0.7.2-py2.7.egg\m
ako\template.py", line 291, in __init__
module = self._compile_from_file(path, filename)
File "C:\Program Files (x86)\Python27\lib\site-packages\mako-0.7.2-py2.7.egg\m
ako\template.py", line 368, in _compile_from_file
filename)
File "C:\Program Files (x86)\Python27\lib\site-packages\mako-0.7.2-py2.7.egg\m
ako\template.py", line 615, in _compile_text
generate_magic_comment=template.disable_unicode)
File "C:\Program Files (x86)\Python27\lib\site-packages\mako-0.7.2-py2.7.egg\m
ako\template.py", line 597, in _compile
node = lexer.parse()
File "C:\Program Files (x86)\Python27\lib\site-packages\mako-0.7.2-py2.7.egg\m
ako\lexer.py", line 214, in parse
self.filename,)
File "C:\Program Files (x86)\Python27\lib\site-packages\mako-0.7.2-py2.7.egg\m
ako\lexer.py", line 206, in decode_raw_stream
0, 0, filename)
mako.exceptions.CompileException: Unicode decode operation of encoding 'utf-8' f
ailed in file '_templates/site.mako' at line: 0 char: 0
Okay, I just found out that everything works for me when I set the locale completely to English by putting this into config.py:
def pre_build():
import locale
locale.setlocale(locale.LC_ALL, 'english')
(thanks to Peter Zsoldos for pointing me to this)
So the problem has disappeared for me, but everyone who tries to use Blogofile to blog in German (or, probably, any language containing umlauts) will still have the same problem.
Same issue of #136, #138, #147, #148 and #152
TL;DR:
Blogofile crashes when I set the post date to a date where the month name in my machine's default language contains an umlaut (in my case, the language is German and the umlaut is in "März", which is the German word for the month March).
I avoided the problem by setting the locale to English before the build. This works for me because I want to blog in English anyway, but it won't work for people who want to blog in a language with umlauts.
Long version:
I just discovered Blogofile a few hours ago, and I'm just trying to create my first site. I ran into this issue first when I created a new site, and tried to add a new post (with a date in March 2012) to it.
Then I discovered that I get the same error when I change the post date in one of the default example posts. After playing around with some test values, I found out that this error occurs whenever I set the post date to a value between March 1st and March 31st, no matter which year (I tested 2009 to 2012).
Here are the steps to reproduce the problem:
I'm using:
I create a new site according to the quick tutorial:
Blogofile compiles and I can view the site via http://localhost:8080.
Then I change the YAML header of this file:
By default, the header says this:
I change the month to March:
Then I try to build the site again:
Blogofile crashes and outputs this: