summaryrefslogtreecommitdiff
path: root/src/mailman/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/commands')
-rw-r--r--src/mailman/commands/cli_withlist.py6
-rw-r--r--src/mailman/commands/tests/test_control.py16
2 files changed, 5 insertions, 17 deletions
diff --git a/src/mailman/commands/cli_withlist.py b/src/mailman/commands/cli_withlist.py
index 79dc3b966..127308a05 100644
--- a/src/mailman/commands/cli_withlist.py
+++ b/src/mailman/commands/cli_withlist.py
@@ -20,7 +20,7 @@
import re
import sys
-from contextlib import ExitStack
+from contextlib import ExitStack, suppress
from functools import partial
from lazr.config import as_boolean
from mailman import public
@@ -222,10 +222,8 @@ class Withlist:
}
history_file = Template(
history_file_template).safe_substitute(substitutions)
- try:
+ with suppress(FileNotFoundError):
readline.read_history_file(history_file)
- except FileNotFoundError:
- pass
resources.callback(
readline.write_history_file,
history_file)
diff --git a/src/mailman/commands/tests/test_control.py b/src/mailman/commands/tests/test_control.py
index 26d921cd7..7377c4666 100644
--- a/src/mailman/commands/tests/test_control.py
+++ b/src/mailman/commands/tests/test_control.py
@@ -56,22 +56,12 @@ def find_master():
until = timedelta(seconds=10) + datetime.now()
while datetime.now() < until:
time.sleep(0.1)
- try:
+ with suppress(FileNotFoundError, ValueError, ProcessLookupError):
with open(config.PID_FILE) as fp:
pid = int(fp.read().strip())
os.kill(pid, 0)
- except IOError as error:
- if error.errno != errno.ENOENT:
- raise
- except ValueError:
- pass
- except OSError as error:
- if error.errno != errno.ESRCH:
- raise
- else:
- return pid
- else:
- return None
+ return pid
+ return None
class FakeArgs: