Repository: getnikola/nikola

Issue:
galleries fail to build on sites whose titles contain non-ASCII characters
I felt like playing around with various things.  So, I created an empty blog with `BLOG_TITLE='My Nikölä site'`.  And it crashed:

``` pytb
Scanning posts....done!
########################################
DependencyError - taskid:render_galleries:output/galleries
ERROR: Task 'render_galleries:output/galleries' checking dependencies
Traceback (most recent call last):
  File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/doit/runner.py", line 124, in select_task
    node.run_status = self.dep_manager.get_status(task, tasks_dict)
  File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/doit/dependency.py", line 483, in get_status
    uptodate_result = utd(*args, **utd_kwargs)
  File "/home/kwpolska/virtualenvs/nikola-py2/lib/python2.7/site-packages/doit/tools.py", line 122, in __call__
    self.config_digest = self._calc_digest()
  File "/home/kwpolska/git/nikola/nikola/utils.py", line 501, in _calc_digest
    data = json.dumps(self.config, cls=CustomEncoder, sort_keys=True)
  File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/usr/lib64/python2.7/json/encoder.py", line 209, in encode
    chunks = list(chunks)
  File "/usr/lib64/python2.7/json/encoder.py", line 434, in _iterencode
    for chunk in _iterencode_dict(o, _current_indent_level):
  File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib64/python2.7/json/encoder.py", line 442, in _iterencode
    o = _default(o)
  File "/home/kwpolska/git/nikola/nikola/utils.py", line 488, in default
    return super(CustomEncoder, self).default(obj)
  File "/usr/lib64/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 20: ordinal not in range(128)
```



Discussion:

Resolving patch:
diff --git a/nikola/nikola.py b/nikola/nikola.py
--- a/nikola/nikola.py
+++ b/nikola/nikola.py
@@ -1313,7 +1313,7 @@ def generic_post_list_renderer(self, lang, posts, output_name,
         return utils.apply_filters(task, filters)
 
     def __repr__(self):
-        return '<Nikola Site: {0}>'.format(self.config['BLOG_TITLE']())
+        return '<Nikola Site: {0!r}>'.format(self.config['BLOG_TITLE']())
 
 
 def sanitized_locales(locale_fallback, locale_default, locales, translations):
diff --git a/nikola/utils.py b/nikola/utils.py
--- a/nikola/utils.py
+++ b/nikola/utils.py
@@ -332,14 +332,7 @@ def __unicode__(self):
 
     def __repr__(self):
         """Provide a representation for programmers."""
-        header = '<TranslatableSetting> '
-
-        if not self.translated:
-            values = [repr(self())]
-        else:
-            values = ['{0}={1!r}'.format(k, v) for k, v in self.values.items()]
-
-        return header + ', '.join(values)
+        return '<TranslatableSetting: {0!r}>'.format(self.name)
 
     def format(self, *args, **kwargs):
         """Format ALL the values in the setting the same way."""


Test patch: