unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomas Nordin <tomasn@posteo.net>
To: Matthew Lear <matt@bubblegen.co.uk>, Brian Sniffen <bts@evenmere.org>
Cc: notmuch@notmuchmail.org,
	Vladimir Panteleev <thecybershadow@gmail.com>,
	Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Subject: Re: web interface to notmuch
Date: Tue, 31 Oct 2017 19:47:34 +0100	[thread overview]
Message-ID: <87vaiv40jd.fsf@fliptop> (raw)
In-Reply-To: <CAJFxaw8dDcPpJvQWmpJqjjXeFy=z9chA4bF0pJnw=_f6bxNi-Q@mail.gmail.com>

Hi Matthew

Sorry for just chiming in here out of the blue. I don't really know
anything on the code you are discussing, but I have some experience with
python.

Matthew Lear <matt@bubblegen.co.uk> writes:

> Traceback (most recent call last):
>   File "/usr/lib/python2.7/dist-packages/web/application.py", line 239, in
> process
>     return self.handle()
>   File "/usr/lib/python2.7/dist-packages/web/application.py", line 230, in
> handle
>     return self._delegate(fn, self.fvars, args)
>   File "/usr/lib/python2.7/dist-packages/web/application.py", line 420, in
> _delegate
>     return handle_class(cls)
>   File "/usr/lib/python2.7/dist-packages/web/application.py", line 396, in
> handle_class
>     return tocall(*args)
>   File "/b/git/notmuch-brians.git/contrib/notmuch-web/nmweb.py", line 153,
> in GET
>     sprefix=webprefix)
>   File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989,
> in render
>     return self.environment.handle_exception(exc_info, True)
>   File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754,
> in handle_exception
>     reraise(exc_type, exc_value, tb)
>   File "templates/show.html", line 1, in top-level template code
>     {% extends "base.html" %}
>   File "templates/base.html", line 32, in top-level template code
>     {% block content %}
>   File "templates/show.html", line 12, in block "content"
>     {% for part in format_message(m.get_filename(),mid): %}{{ part|safe
> }}{% endfor %}
>   File "/b/git/notmuch-brians.git/contrib/notmuch-web/nmweb.py", line 245,
> in format_message_walk
>     tags=safe_tags).encode(part.get_content_charset('ascii')))

My guess is that the function part.get_content_charset is requesting the
encoding used for a message, providing 'ascii' as a backup if not found.
It is getting 'latin-1', which is hence tried for encoding output.

> UnicodeEncodeError: 'latin-1' codec can't encode character u'\u201c'
> in position 1141: ordinal not in range(256)

Here is an interactive python session to reproduce:

>>> u = u'\u201c'
>>> u
u'\u201c'
>>> type(u)
<type 'unicode'> # (un-encoded)
>>> u.encode('utf-8')
'\xe2\x80\x9c'   # utf-8 for encoding work fine
>>> print u.encode('utf-8')
>>> print u.encode('latin-1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'latin-1' codec can't encode character u'\u201c' in position 0: ordinal not in range(256)

The character is not encodable with latin-1. So one should check that
the function getting the encoding is doing a proper job and if so blame
the message information.

Just my 2 cents

Best regards
--
Tomas

  reply	other threads:[~2017-10-31 18:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 14:43 web interface to notmuch Matthew Lear
2017-10-19 15:01 ` Brian Sniffen
2017-10-19 16:55   ` Daniel Kahn Gillmor
2017-10-19 20:00     ` Brian Sniffen
2017-10-19 20:13       ` Daniel Kahn Gillmor
2017-10-21 20:00     ` Jani Nikula
2017-10-21 22:21       ` Daniel Kahn Gillmor
2017-10-24 12:39         ` Vladimir Panteleev
     [not found]         ` <27e53def-32b4-45ab-1192-77cc0e837a93@gmail.com>
2017-10-24 20:03           ` Matthew Lear
2017-10-25 22:03           ` Brian Sniffen
2017-10-26 21:25             ` Daniel Kahn Gillmor
2017-10-27  4:04               ` Brian Sniffen
2017-10-27  4:24                 ` Daniel Kahn Gillmor
2017-10-27 10:02                   ` Matthew Lear
2017-10-27  6:05                 ` Daniel Kahn Gillmor
2017-10-27 17:52                   ` Brian Sniffen
2017-10-31 17:13                     ` Matthew Lear
2017-10-31 18:47                       ` Tomas Nordin [this message]
2017-10-31 19:21                       ` Brian Sniffen
2017-10-31 21:32                         ` Matthew Lear
2017-11-01 13:01                           ` Matthew Lear
2017-11-01 14:38                           ` Brian Sniffen
2017-11-02 17:32                             ` Matthew Lear
2017-12-06 15:00     ` Brian Sniffen
2017-12-06 19:13       ` Daniel Kahn Gillmor
2017-12-07  1:00       ` David Bremner
2017-10-20 19:25 ` W. Trevor King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vaiv40jd.fsf@fliptop \
    --to=tomasn@posteo.net \
    --cc=bts@evenmere.org \
    --cc=dkg@fifthhorseman.net \
    --cc=matt@bubblegen.co.uk \
    --cc=notmuch@notmuchmail.org \
    --cc=thecybershadow@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).