From: Yaroslav Halchenko <debian@onerussian.com>
Subject: BF: do not force "str" if already unicode
  then, if actually was needed, it would need to be encoded, not just str"ed

Lead in 0.8.3 debian package to the failure while running unittests:

====================================================================== ERROR:
Test rendering -*.fif files for mne report.
---------------------------------------------------------------------- Traceback
(most recent call last):
 File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
   self.test(*self.arg)
 File "/home/yoh/deb/gits/pkg-exppsy/mne-python/mne/tests/test_report.py", line
88, in test_render_report
   report.save(fname=op.join(tempdir, 'report.html'), open_browser=False)
 File "/home/yoh/deb/gits/pkg-exppsy/mne-python/mne/report.py", line 825, in
save
   self._render_toc(verbose=self.verbose)
 File "<string>", line 2, in _render_toc
 File "/home/yoh/deb/gits/pkg-exppsy/mne-python/mne/utils.py", line 551, in
verbose
   ret = function(*args, **kwargs)
 File "/home/yoh/deb/gits/pkg-exppsy/mne-python/mne/report.py", line 932, in
_render_toc
   sectionvars=self._sectionvars)
 File
"/home/yoh/deb/gits/pkg-exppsy/mne-python/mne/externals/tempita/__init__.py",
line 178, in substitute
   result, defs, inherit = self._interpret(ns)
 File
"/home/yoh/deb/gits/pkg-exppsy/mne-python/mne/externals/tempita/__init__.py",
line 189, in _interpret
   self._interpret_codes(self._parsed, ns, out=parts, defs=defs)
 File
"/home/yoh/deb/gits/pkg-exppsy/mne-python/mne/externals/tempita/__init__.py",
line 217, in _interpret_codes
   self._interpret_code(item, ns, out, defs)
 File
"/home/yoh/deb/gits/pkg-exppsy/mne-python/mne/externals/tempita/__init__.py",
line 241, in _interpret_code
   out.append(self._repr(base, pos))
 File
"/home/yoh/deb/gits/pkg-exppsy/mne-python/mne/externals/tempita/__init__.py",
line 349, in _repr
   raise(e) UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in
position 14245: ordinal not in range(128)

--- a/mne/externals/tempita/__init__.py
+++ b/mne/externals/tempita/__init__.py
@@ -331,8 +331,8 @@ class Template(object):
                 return ''
             if self._unicode:
                 try:
-                    value = str(value)
                     if not is_unicode(value):
+                        value = str(value)
                         value = value.decode('utf-8')
                 except UnicodeDecodeError:
                     value = bytes(value)
