summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-10-22 16:05:27 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-10-22 16:05:27 +0100
commitcd6d038427535355b7516df043319b989d0ae961 (patch)
tree9bb977f7e63a84920a675d194036a3e1c29511e9
parent1e8e5770654ef637ff6a8056473389c8c31961a4 (diff)
use string_decode instead of str.decode
-rw-r--r--alot/commands/__init__.py3
-rw-r--r--alot/commands/envelope.py3
-rw-r--r--alot/helper.py2
-rw-r--r--alot/message.py3
4 files changed, 6 insertions, 5 deletions
diff --git a/alot/commands/__init__.py b/alot/commands/__init__.py
index d8f1248f..d8552fbb 100644
--- a/alot/commands/__init__.py
+++ b/alot/commands/__init__.py
@@ -8,6 +8,7 @@ import argparse
import cStringIO
import alot.settings
+import alot.helper
class Command(object):
@@ -98,7 +99,7 @@ def commandfactory(cmdline, mode='global'):
args = shlex.split(cmdline.encode('utf-8'))
except ValueError, e:
raise CommandParseError(e.message)
- args = map(lambda x: x.decode('utf-8'), args) # get unicode strings
+ args = map(lambda x: alot.helper.string_decode(x, 'utf-8'), args)
logging.debug('ARGS: %s' % args)
cmdname = args[0]
args = args[1:]
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index aa1ae0da..b44cea0c 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -17,6 +17,7 @@ from alot.message import extract_body
from alot.commands.globals import EditCommand
from alot.commands.globals import BufferCloseCommand
from alot.commands.globals import EnvelopeOpenCommand
+from alot.helper import string_decode
MODE = 'envelope'
@@ -140,7 +141,7 @@ class EnvelopeEditCommand(Command):
# get input
f = open(tf.name)
enc = settings.config.get('general', 'editor_writes_encoding')
- editor_input = f.read().decode(enc)
+ editor_input = string_decode(f.read(), enc)
if self.edit_headers:
headertext, bodytext = editor_input.split('\n\n', 1)
else:
diff --git a/alot/helper.py b/alot/helper.py
index 05f7be66..b1fbaeca 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -165,7 +165,7 @@ def cmd_output(command_line):
args = shlex.split(command_line.encode('utf-8', errors='ignore'))
try:
output = subprocess.check_output(args)
- output = output.decode(urwid.util.detected_encoding, errors='replace')
+ output = string_decode(output, urwid.util.detected_encoding)
except subprocess.CalledProcessError:
return None
except OSError:
diff --git a/alot/message.py b/alot/message.py
index 3afb048a..34d269cf 100644
--- a/alot/message.py
+++ b/alot/message.py
@@ -252,8 +252,7 @@ def decode_header(header):
valuelist = email.header.decode_header(header)
decoded_list = []
for v, enc in valuelist:
- if enc:
- v = v.decode(enc, errors='replace')
+ v = string_decode(v, enc)
decoded_list.append(string_sanitize(v))
return u' '.join(decoded_list)