Use "with suppress()" to suppress a python exception

This commit is contained in:
Luflosi 2020-07-31 15:48:49 +02:00
parent d1b2f9c6a9
commit ee4cedcc81
No known key found for this signature in database
GPG Key ID: 4E41E29EDCC345D0

View File

@ -7,6 +7,7 @@ import re
import shutil
import subprocess
import sys
from contextlib import suppress
from bypy.constants import (
LIBDIR, PREFIX, PYTHON, SRC as KITTY_DIR, ismacos, worker_env
@ -49,10 +50,8 @@ def build_c_extensions(ext_dir, args):
ignore=shutil.ignore_patterns('b', 'build', 'dist', '*_commands.json', '*.o'))
# Build the launcher as it is needed for the spawn test
try:
with suppress(FileNotFoundError):
os.remove(os.path.join(writeable_src_dir, 'kitty', 'launcher', 'kitty'))
except FileNotFoundError:
pass
if run(PYTHON, 'setup.py', 'build-launcher', cwd=writeable_src_dir) != 0:
print('Building of kitty launcher failed', file=sys.stderr)
os.chdir(KITTY_DIR)