diff options
| author | Barry Warsaw | 2016-04-30 13:34:04 -0400 |
|---|---|---|
| committer | GitLab | 2016-04-30 19:54:54 +0000 |
| commit | c6eb7ee3e574b48ee016dd31af2014b0ed083268 (patch) | |
| tree | 14c1f1e7bb382898ee50909333365aab335aa4a1 /src/mailman/commands | |
| parent | 465f24ff33e154385322ee894d32d8b7dd9b3941 (diff) | |
| download | mailman-c6eb7ee3e574b48ee016dd31af2014b0ed083268.tar.gz mailman-c6eb7ee3e574b48ee016dd31af2014b0ed083268.tar.zst mailman-c6eb7ee3e574b48ee016dd31af2014b0ed083268.zip | |
Diffstat (limited to 'src/mailman/commands')
| -rw-r--r-- | src/mailman/commands/cli_withlist.py | 6 | ||||
| -rw-r--r-- | src/mailman/commands/tests/test_control.py | 16 |
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: |
