summaryrefslogtreecommitdiff
path: root/alot/helper.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-06-01 11:02:21 -0700
committerDylan Baker <dylan@pnwbakers.com>2018-03-01 10:34:56 -0800
commita9a41b54c7edb8c81d5f44f0b95373b682bc2499 (patch)
tree7d97115f5a119276241b33eb1b0f835040165c24 /alot/helper.py
parent0b0164b8daeb58fa576c82722a9514dba2e4acac (diff)
py3k: remove basestring and unicode.
This probably isn't completely right, but it's a start.
Diffstat (limited to 'alot/helper.py')
-rw-r--r--alot/helper.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/alot/helper.py b/alot/helper.py
index 400d8c0e..db37f34d 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -41,7 +41,7 @@ def split_commandline(s, comments=False, posix=True):
s = s.replace('\'', '\\\'')
s = s.replace('\"', '\\\"')
# encode s to utf-8 for shlex
- if isinstance(s, unicode):
+ if isinstance(s, str):
s = s.encode('utf-8')
lex = shlex.shlex(s, posix=posix)
lex.whitespace_split = True
@@ -57,7 +57,7 @@ def split_commandstring(cmdstring):
and the like. This simply calls shlex.split but works also with unicode
bytestrings.
"""
- if isinstance(cmdstring, unicode):
+ if isinstance(cmdstring, str):
cmdstring = cmdstring.encode('utf-8', errors='ignore')
return shlex.split(cmdstring)
@@ -118,10 +118,10 @@ def string_decode(string, enc='ascii'):
if enc is None:
enc = 'ascii'
try:
- string = unicode(string, enc, errors='replace')
+ string = str(string, enc, errors='replace')
except LookupError: # malformed enc string
string = string.decode('ascii', errors='replace')
- except TypeError: # already unicode
+ except TypeError: # already str
pass
return string