Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError when trying to reply to mail #9

Closed
lmacken opened this issue Aug 14, 2011 · 4 comments
Closed

UnicodeDecodeError when trying to reply to mail #9

lmacken opened this issue Aug 14, 2011 · 4 comments
Milestone

Comments

@lmacken
Copy link
Contributor

lmacken commented Aug 14, 2011

I get the following traceback when trying to reply to a mail from someone with a non-ascii name.

Traceback (most recent call last):
  File "/home/lmacken/code/github.org/alot/env/bin/alot", line 20, in <module>
    main()
  File "/home/lmacken/code/github.org/alot/env/lib/python2.7/site-packages/alot/init.py", line 90, in main
    args.colours,
  File "/home/lmacken/code/github.org/alot/env/lib/python2.7/site-packages/alot/ui.py", line 74, in __init__
    self.mainloop.run()
  File "/home/lmacken/code/github.org/alot/env/lib/python2.7/site-packages/urwid-1.0.0-py2.7-linux-x86_64.egg/urwid/main_loop.py", line 271, in run
    self.screen.run_wrapper(self._run)
  File "/home/lmacken/code/github.org/alot/env/lib/python2.7/site-packages/urwid-1.0.0-py2.7-linux-x86_64.egg/urwid/raw_display.py", line 228, in run_wrapper
    return fn()
  File "/home/lmacken/code/github.org/alot/env/lib/python2.7/site-packages/urwid-1.0.0-py2.7-linux-x86_64.egg/urwid/main_loop.py", line 292, in _run
    self.event_loop.run()
  File "/home/lmacken/code/github.org/alot/env/lib/python2.7/site-packages/urwid-1.0.0-py2.7-linux-x86_64.egg/urwid/main_loop.py", line 667, in run
    self._loop()
  File "/home/lmacken/code/github.org/alot/env/lib/python2.7/site-packages/urwid-1.0.0-py2.7-linux-x86_64.egg/urwid/main_loop.py", line 705, in _loop
    self._watch_files[fd]()
  File "/home/lmacken/code/github.org/alot/env/lib/python2.7/site-packages/urwid-1.0.0-py2.7-linux-x86_64.egg/urwid/main_loop.py", line 343, in _update
    self.process_input(keys)
  File "/home/lmacken/code/github.org/alot/env/lib/python2.7/site-packages/urwid-1.0.0-py2.7-linux-x86_64.egg/urwid/main_loop.py", line 432, in process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/home/lmacken/code/github.org/alot/env/lib/python2.7/site-packages/alot/ui.py", line 42, in keypress
    self.ui.apply_command(cmd)
  File "/home/lmacken/code/github.org/alot/env/lib/python2.7/site-packages/alot/ui.py", line 349, in apply_command
    cmd.apply(self)
  File "/home/lmacken/code/github.org/alot/env/lib/python2.7/site-packages/alot/command.py", line 481, in apply
    mailcontent += '>' + line + '\n'
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 17: ordinal not in range(128)
@lmacken
Copy link
Contributor Author

lmacken commented Aug 14, 2011

This seems to do the trick.

commit 853e9964906ec5fba8a1058e2a796c053deb771c
Author: Luke Macken <lmacken@redhat.com>
Date:   Sun Aug 14 12:34:26 2011 -0400

    Decode our author names to unicode before encoding to UTF-8 when replying

diff --git a/alot/command.py b/alot/command.py
index 711bfd8..f569bd0 100644
--- a/alot/command.py
+++ b/alot/command.py
@@ -476,7 +476,7 @@ class ReplyCommand(Command):
         mail = self.message.get_email()
         # set body text
         mailcontent = '\nOn %s, %s wrote:\n' % (self.message.get_datestring(),
-                self.message.get_author()[0])
+                self.message.get_author()[0].decode('utf-8'))
         for line in self.message.accumulate_body().splitlines():
             mailcontent += '>' + line + '\n'


@pazz
Copy link
Owner

pazz commented Aug 14, 2011

ah yes, i remember this one: i deliberately removed this decode because spaetz agreed to
return valid unicode strings. a patch for the api has already been filed to the notmuch ml,
but is not yet applied. i am reluctant to fix this here because its going to be a non-issue
once spaetz pushes the api patch.
anyway, thanks for the issue.. keep them comming :p
/p

Sent via Hubroid

@lmacken
Copy link
Contributor Author

lmacken commented Aug 14, 2011

Great, sounds good to me!

Ensuring that the API always returns unicode definitely is ideal, as my patch doesn't exactly fit the "decode early, encode late. unicode everywhere." methodology :)

@pazz
Copy link
Owner

pazz commented Aug 15, 2011

i'll close this here as spaetz has just pushed my patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants