summaryrefslogtreecommitdiff
path: root/alot/ui.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2018-01-28 12:38:17 +0000
committerGitHub <noreply@github.com>2018-01-28 12:38:17 +0000
commite519e9f4ef20e6ad6e784e092e1ea8f7065faf79 (patch)
treea7d2d014d721578b4812ff9a06454a1ea17e92a0 /alot/ui.py
parent6a62b0e3659d377cd9854223fc5f5a1ece666eb5 (diff)
parentbf25b1a9dd6f9183ca053dee6677401e7438f7f2 (diff)
Merge pull request #1190 from three-comrades/write_history
[WIP] Fix writing/loading history, if a command contains non-ascii character(s)
Diffstat (limited to 'alot/ui.py')
-rw-r--r--alot/ui.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/alot/ui.py b/alot/ui.py
index c42df091..f82feda4 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -6,6 +6,7 @@ from __future__ import absolute_import
import logging
import os
import signal
+import codecs
from twisted.internet import reactor, defer, task
import urwid
@@ -730,7 +731,7 @@ class UI(object):
if size == 0:
return []
if os.path.exists(path):
- with open(path) as histfile:
+ with codecs.open(path, 'r', encoding='utf-8') as histfile:
lines = [line.rstrip('\n') for line in histfile]
if size > 0:
lines = lines[-size:]
@@ -760,7 +761,7 @@ class UI(object):
if not os.path.exists(directory):
os.makedirs(directory)
# Write linewise to avoid building a large string in menory.
- with open(path, 'w') as histfile:
+ with codecs.open(path, 'w', encoding='utf-8') as histfile:
for line in history:
histfile.write(line)
histfile.write('\n')