From 3fb4d66b584beb3fc91fc22708cd83b125b567d9 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 16 Jan 2021 10:49:06 +0100 Subject: helper: get rid of decode_string() It just adds unnecessary type confusion. In most places where it is used, the types are always str, so it does nothing. In the few others, the encoding/decoding is better handled explicitly. --- alot/commands/__init__.py | 3 +-- alot/commands/envelope.py | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'alot/commands') diff --git a/alot/commands/__init__.py b/alot/commands/__init__.py index 1e16b4d4..61ff7f21 100644 --- a/alot/commands/__init__.py +++ b/alot/commands/__init__.py @@ -8,7 +8,7 @@ import os import re from ..settings.const import settings -from ..helper import split_commandstring, string_decode +from ..helper import split_commandstring class Command: @@ -167,7 +167,6 @@ def commandfactory(cmdline, mode='global'): args = split_commandstring(cmdline) except ValueError as e: raise CommandParseError(str(e)) - args = [string_decode(x, 'utf-8') for x in 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 914829eb..1f806581 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -23,7 +23,6 @@ from .. import crypto from ..account import SendingMailFailed, StoreMailError from ..db.errors import DatabaseError from ..errors import GPGProblem -from ..helper import string_decode from ..settings.const import settings from ..settings.errors import NoMatchingAccount from ..utils import argparse as cargparse @@ -357,8 +356,8 @@ class EditCommand(Command): # get input # tempfile will be removed on buffer cleanup enc = settings.get('editor_writes_encoding') - with open(self.envelope.tmpfile.name) as f: - template = string_decode(f.read(), enc) + with open(self.envelope.tmpfile.name, 'rb') as f: + template = f.read().decode(enc) # call post-edit translate hook translate = settings.get_hook('post_edit_translate') -- cgit v1.2.3