summaryrefslogtreecommitdiff
path: root/src/mailman/runners
diff options
context:
space:
mode:
authorBarry Warsaw2016-04-30 13:34:04 -0400
committerGitLab2016-04-30 19:54:54 +0000
commitc6eb7ee3e574b48ee016dd31af2014b0ed083268 (patch)
tree14c1f1e7bb382898ee50909333365aab335aa4a1 /src/mailman/runners
parent465f24ff33e154385322ee894d32d8b7dd9b3941 (diff)
downloadmailman-c6eb7ee3e574b48ee016dd31af2014b0ed083268.tar.gz
mailman-c6eb7ee3e574b48ee016dd31af2014b0ed083268.tar.zst
mailman-c6eb7ee3e574b48ee016dd31af2014b0ed083268.zip
Use contextlib.suppress() where appropriate.
Diffstat (limited to 'src/mailman/runners')
-rw-r--r--src/mailman/runners/command.py5
-rw-r--r--src/mailman/runners/incoming.py5
2 files changed, 4 insertions, 6 deletions
diff --git a/src/mailman/runners/command.py b/src/mailman/runners/command.py
index 13d52ce75..00f6f416b 100644
--- a/src/mailman/runners/command.py
+++ b/src/mailman/runners/command.py
@@ -25,6 +25,7 @@
import re
import logging
+from contextlib import suppress
from email.errors import HeaderParseError
from email.header import decode_header, make_header
from email.iterators import typed_subpart_iterator
@@ -224,11 +225,9 @@ class CommandRunner(Runner):
# utf-8.
reply_body = str(results)
for charset in (results.charset, 'us-ascii', 'latin-1'):
- try:
+ with suppress(UnicodeError):
reply_body.encode(charset)
break
- except UnicodeError:
- pass
else:
charset = 'utf-8'
reply.set_payload(reply_body, charset=charset)
diff --git a/src/mailman/runners/incoming.py b/src/mailman/runners/incoming.py
index dd9254194..62b12dab1 100644
--- a/src/mailman/runners/incoming.py
+++ b/src/mailman/runners/incoming.py
@@ -26,6 +26,7 @@ prepared for delivery. Rejections, discards, and holds are processed
immediately.
"""
+from contextlib import suppress
from mailman import public
from mailman.core.chains import process
from mailman.core.runner import Runner
@@ -48,10 +49,8 @@ class IncomingRunner(Runner):
user_manager = getUtility(IUserManager)
with transaction():
for sender in msg.senders:
- try:
+ with suppress(ExistingAddressError):
user_manager.create_address(sender)
- except ExistingAddressError:
- pass
# Process the message through the mailing list's start chain.
start_chain = (mlist.owner_chain
if msgdata.get('to_owner', False)