summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-08-16 11:37:31 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-08-19 12:52:26 -0700
commitdee41bb04906d6976b4f7c05c222f7d95182b3ea (patch)
tree2dbe16e47e3b8fee167d9375e83bd42585e78464
parent188d79a0189b480656542a09be348fcbf506f33d (diff)
Replace Exception.message with str(Exception)
In python3 Exception doesn't have a message attribute, the only way to get the string output is to call str() on the Exception. This also works in python 2.7, so go ahead and make that change.
-rw-r--r--alot/commands/__init__.py2
-rw-r--r--alot/commands/envelope.py10
-rw-r--r--alot/commands/thread.py6
-rw-r--r--alot/commands/utils.py2
-rw-r--r--alot/crypto.py4
-rw-r--r--alot/errors.py1
-rw-r--r--alot/settings/manager.py2
-rw-r--r--alot/settings/utils.py2
-rw-r--r--alot/ui.py2
-rw-r--r--alot/utils/configobj.py4
10 files changed, 18 insertions, 17 deletions
diff --git a/alot/commands/__init__.py b/alot/commands/__init__.py
index 351fc993..0638926a 100644
--- a/alot/commands/__init__.py
+++ b/alot/commands/__init__.py
@@ -167,7 +167,7 @@ def commandfactory(cmdline, mode='global'):
try:
args = split_commandstring(cmdline)
except ValueError as e:
- raise CommandParseError(e.message)
+ raise CommandParseError(str(e))
args = [string_decode(x, 'utf-8') for x in args]
logging.debug('ARGS: %s', args)
cmdname = args[0]
diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py
index b9ff51d6..4d2963ee 100644
--- a/alot/commands/envelope.py
+++ b/alot/commands/envelope.py
@@ -146,8 +146,8 @@ class SaveCommand(Command):
ui.apply_command(globals.FlushCommand())
ui.apply_command(commands.globals.BufferCloseCommand())
except DatabaseError as e:
- logging.error(e.message)
- ui.notify('could not index message:\n%s' % e.message,
+ logging.error(e)
+ ui.notify('could not index message:\n%s' % e,
priority='error',
block=True)
else:
@@ -217,7 +217,7 @@ class SendCommand(Command):
self.mail = email_as_string(self.mail)
except GPGProblem as e:
ui.clear_notify([clearme])
- ui.notify(e.message, priority='error')
+ ui.notify(str(e), priority='error')
return
ui.clear_notify([clearme])
@@ -499,7 +499,7 @@ class SignCommand(Command):
sign=True)
except GPGProblem as e:
envelope.sign = False
- ui.notify(e.message, priority='error')
+ ui.notify(str(e), priority='error')
return
else:
try:
@@ -571,7 +571,7 @@ class EncryptCommand(Command):
tmp_key = crypto.get_key(keyid)
del envelope.encrypt_keys[tmp_key.fpr]
except GPGProblem as e:
- ui.notify(e.message, priority='error')
+ ui.notify(str(e), priority='error')
if not envelope.encrypt_keys:
envelope.encrypt = False
ui.current_buffer.rebuild()
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index acbb4e28..d73ef622 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -186,7 +186,7 @@ class ReplyCommand(Command):
try:
from_header, _ = determine_sender(mail, 'reply')
except AssertionError as e:
- ui.notify(e.message, priority='error')
+ ui.notify(str(e), priority='error')
return
envelope.add('From', from_header)
@@ -394,7 +394,7 @@ class ForwardCommand(Command):
try:
from_header, _ = determine_sender(mail, 'reply')
except AssertionError as e:
- ui.notify(e.message, priority='error')
+ ui.notify(str(e), priority='error')
return
envelope.add('From', from_header)
@@ -441,7 +441,7 @@ class BounceMailCommand(Command):
try:
resent_from_header, account = determine_sender(mail, 'bounce')
except AssertionError as e:
- ui.notify(e.message, priority='error')
+ ui.notify(str(e), priority='error')
return
mail['Resent-From'] = resent_from_header
diff --git a/alot/commands/utils.py b/alot/commands/utils.py
index 0aa80656..1bf64cbb 100644
--- a/alot/commands/utils.py
+++ b/alot/commands/utils.py
@@ -86,7 +86,7 @@ def _get_keys(ui, encrypt_keyids, block_error=False, signed_only=False):
encrypt_keyids.append(keyid)
continue
else:
- ui.notify(e.message, priority='error', block=block_error)
+ ui.notify(str(e), priority='error', block=block_error)
continue
keys[key.fpr] = key
returnValue(keys)
diff --git a/alot/crypto.py b/alot/crypto.py
index cd03d9e7..52eb8c58 100644
--- a/alot/crypto.py
+++ b/alot/crypto.py
@@ -196,7 +196,7 @@ def verify_detached(message, signature):
except gpg.errors.BadSignatures as e:
raise GPGProblem(str(e), code=GPGCode.BAD_SIGNATURE)
except gpg.errors.GPGMEError as e:
- raise GPGProblem(e.message, code=e.getcode())
+ raise GPGProblem(str(e), code=e.getcode())
def decrypt_verify(encrypted):
@@ -212,7 +212,7 @@ def decrypt_verify(encrypted):
try:
(plaintext, _, verify_result) = ctx.decrypt(encrypted, verify=True)
except gpg.errors.GPGMEError as e:
- raise GPGProblem(e.message, code=e.getcode())
+ raise GPGProblem(str(e), code=e.getcode())
# what if the signature is bad?
return verify_result.signatures, plaintext
diff --git a/alot/errors.py b/alot/errors.py
index c312e674..b9763192 100644
--- a/alot/errors.py
+++ b/alot/errors.py
@@ -19,6 +19,7 @@ class GPGCode(object):
class GPGProblem(Exception):
"""GPG Error"""
+
def __init__(self, message, code):
self.code = code
super(GPGProblem, self).__init__(message)
diff --git a/alot/settings/manager.py b/alot/settings/manager.py
index 6f9273c2..6c9e80fe 100644
--- a/alot/settings/manager.py
+++ b/alot/settings/manager.py
@@ -123,7 +123,7 @@ class SettingsManager(object):
except ConfigError as e:
logging.warning(
'Theme file %s failed validation: %s',
- themestring, str(e.message))
+ themestring, e)
else:
break
else:
diff --git a/alot/settings/utils.py b/alot/settings/utils.py
index 23278607..ea56b264 100644
--- a/alot/settings/utils.py
+++ b/alot/settings/utils.py
@@ -44,7 +44,7 @@ def read_config(configpath=None, specpath=None, checks=None):
try:
results = config.validate(validator, preserve_errors=True)
except ConfigObjError as e:
- raise ConfigError(e.message)
+ raise ConfigError(str(e))
if results is not True:
error_msg = ''
diff --git a/alot/ui.py b/alot/ui.py
index e7964ef4..da15cb37 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -174,7 +174,7 @@ class UI(object):
try:
self.apply_commandline(cmdline)
except CommandParseError as e:
- self.notify(e.message, priority='error')
+ self.notify(str(e), priority='error')
# move keys are always passed
elif cmdline in ['move up', 'move down', 'move page up',
'move page down']:
diff --git a/alot/utils/configobj.py b/alot/utils/configobj.py
index 5e04409a..d7ce48a4 100644
--- a/alot/utils/configobj.py
+++ b/alot/utils/configobj.py
@@ -47,7 +47,7 @@ def attr_triple(value):
normal = AttrSpec(acc['16fg'], acc['16bg'], 16)
high = AttrSpec(acc['256fg'], acc['256bg'], 256)
except AttrSpecError as e:
- raise ValidateError(e.message)
+ raise ValidateError(str(e))
return mono, normal, high
@@ -141,4 +141,4 @@ def gpg_key(value):
try:
return crypto.get_key(value)
except GPGProblem as e:
- raise ValidateError(e.message)
+ raise ValidateError(str(e))