[PATCH v2 14/20] nmbug-status: Encode output using the user's locale

Tomi Ollila tomi.ollila at iki.fi
Tue Feb 11 06:14:45 PST 2014


On Tue, Feb 11 2014, David Bremner <david at tethera.net> wrote:

> "W. Trevor King" <wking at tremily.us> writes:
>
>> Instead of always writing UTF-8, allow the user to configure the
>> output encoding using their locale.  This is useful for previewing
>> output in the terminal, for poor souls that don't use UTF-8 locales
>> ;).
>
> This (or some other patch in the series) seems to cause some problems on
> the production instance:
>
> remote: Traceback (most recent call last):
> remote:   File "/home/nmbug/tools/nmbug-status", line 336, in <module>
> remote:     page.write(database=db, views=config['views'])
> remote:   File "/home/nmbug/tools/nmbug-status", line 96, in write
> remote:     self._write_view(database=database, view=view, stream=stream)
> remote:   File "/home/nmbug/tools/nmbug-status", line 115, in _write_view
> remote:     self._write_threads(threads=threads, stream=stream)
> remote:   File "/home/nmbug/tools/nmbug-status", line 219, in _write_threads
> remote:     ).format(**message_display_data))
> remote:   File "/usr/lib/python2.6/codecs.py", line 351, in write
> remote:     data, consumed = self.encode(object, self.errors)
> remote: UnicodeEncodeError: 'ascii' codec can't encode character u'\u017b' in position 219: ordinal not in range(128)
>
> possibly because of
>
> LANG=C
> LANGUAGE=
> LC_CTYPE="C"
> LC_NUMERIC="C"
> LC_TIME="C"
> LC_COLLATE="C"
> LC_MONETARY="C"
> LC_MESSAGES="C"
> LC_PAPER="C"
> LC_NAME="C"
> LC_ADDRESS="C"
> LC_TELEPHONE="C"
> LC_MEASUREMENT="C"
> LC_IDENTIFICATION="C"
> LC_ALL=C
>
> I think it's fine to _allow_ the user to configure the output encoding. I'm
> less sure about _requiring_ it.

That reminded me that yesterday (after review, of course) I thought that 
we probably want configuration file to be parsed as utf-8 instead of
any encoding user may have in their system...

> d

Tomi


More information about the notmuch mailing list