diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2018-01-28 12:38:17 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-28 12:38:17 +0000 |
commit | e519e9f4ef20e6ad6e784e092e1ea8f7065faf79 (patch) | |
tree | a7d2d014d721578b4812ff9a06454a1ea17e92a0 /alot/ui.py | |
parent | 6a62b0e3659d377cd9854223fc5f5a1ece666eb5 (diff) | |
parent | bf25b1a9dd6f9183ca053dee6677401e7438f7f2 (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.py | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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') |