summaryrefslogtreecommitdiff
path: root/alot
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
parent0b0164b8daeb58fa576c82722a9514dba2e4acac (diff)
py3k: remove basestring and unicode.
This probably isn't completely right, but it's a start.
Diffstat (limited to 'alot')
-rw-r--r--alot/buffers.py2
-rw-r--r--alot/commands/globals.py6
-rw-r--r--alot/commands/thread.py2
-rw-r--r--alot/db/envelope.py2
-rw-r--r--alot/db/manager.py2
-rw-r--r--alot/db/utils.py3
-rw-r--r--alot/helper.py8
-rw-r--r--alot/utils/argparse.py2
8 files changed, 14 insertions, 13 deletions
diff --git a/alot/buffers.py b/alot/buffers.py
index d1c6583b..e04ae342 100644
--- a/alot/buffers.py
+++ b/alot/buffers.py
@@ -662,7 +662,7 @@ class TagListBuffer(Buffer):
lines = list()
displayedtags = sorted((t for t in self.tags if self.filtfun(t)),
- key=unicode.lower)
+ key=str.lower)
for (num, b) in enumerate(displayedtags):
if (num % 2) == 0:
attr = settings.get_theming_attribute('taglist', 'line_even')
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index 4e0ed506..228502e7 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -211,7 +211,7 @@ class ExternalCommand(Command):
"""
logging.debug({'spawn': spawn})
# make sure cmd is a list of str
- if isinstance(cmd, unicode):
+ if isinstance(cmd, str):
# convert cmdstring to list: in case shell==True,
# Popen passes only the first item in the list to $SHELL
cmd = [cmd] if shell else split_commandstring(cmd)
@@ -249,8 +249,8 @@ class ExternalCommand(Command):
# set standard input for subcommand
stdin = None
if self.stdin is not None:
- # wrap strings in StringIO so that they behave like files
- if isinstance(self.stdin, unicode):
+ # wrap strings in StrinIO so that they behaves like a file
+ if isinstance(self.stdin, str):
stdin = StringIO(self.stdin)
else:
stdin = self.stdin
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 5e014142..c8fb634c 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -689,7 +689,7 @@ class PipeCommand(Command):
:type field_key: str
"""
Command.__init__(self, **kwargs)
- if isinstance(cmd, unicode):
+ if isinstance(cmd, str):
cmd = split_commandstring(cmd)
self.cmd = cmd
self.whole_thread = all
diff --git a/alot/db/envelope.py b/alot/db/envelope.py
index 017dbaa4..bb440a00 100644
--- a/alot/db/envelope.py
+++ b/alot/db/envelope.py
@@ -155,7 +155,7 @@ class Envelope(object):
if isinstance(attachment, Attachment):
self.attachments.append(attachment)
- elif isinstance(attachment, basestring):
+ elif isinstance(attachment, str):
path = os.path.expanduser(attachment)
part = helper.mimewrap(path, filename, ctype)
self.attachments.append(Attachment(part))
diff --git a/alot/db/manager.py b/alot/db/manager.py
index 93a38b81..2803d1d6 100644
--- a/alot/db/manager.py
+++ b/alot/db/manager.py
@@ -195,7 +195,7 @@ class DBManager(object):
except (XapianError, NotmuchError) as e:
logging.exception(e)
self.writequeue.appendleft(current_item)
- raise DatabaseError(unicode(e))
+ raise DatabaseError(str(e))
except DatabaseLockedError as e:
logging.debug('index temporarily locked')
self.writequeue.appendleft(current_item)
diff --git a/alot/db/utils.py b/alot/db/utils.py
index f57d62bd..39bd9007 100644
--- a/alot/db/utils.py
+++ b/alot/db/utils.py
@@ -403,11 +403,12 @@ def decode_header(header, normalize=False):
:type header: str
:param normalize: replace trailing spaces after newlines
:type normalize: bool
- :rtype: unicode
+ :rtype: str
"""
# If the value isn't ascii as RFC2822 prescribes,
# we just return the unicode bytestring as is
+ # XXX: this prbably isn't going to work in python 3
value = string_decode(header) # convert to unicode
try:
value = value.encode('ascii')
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
diff --git a/alot/utils/argparse.py b/alot/utils/argparse.py
index ff19030c..9822882d 100644
--- a/alot/utils/argparse.py
+++ b/alot/utils/argparse.py
@@ -52,7 +52,7 @@ def _path_factory(check):
@functools.wraps(check)
def validator(paths):
- if isinstance(paths, basestring):
+ if isinstance(paths, str):
check(paths)
elif isinstance(paths, collections.Sequence):
for path in paths: