From 10eafd196d38b0aed7229b6a2f6681f57f56d85e Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Thu, 14 Sep 2023 08:42:14 +0200 Subject: [PATCH] PICARD-2754: Handle launche with relative path and without valid cwd If Picard gets called with a relative path but cwd is invalid (e.g. removed before actual launch) resolving the path lead to a crash. Handle this error now by the file loading code --- picard/tagger.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/picard/tagger.py b/picard/tagger.py index 9e0ae56a33..5c1f1dcf38 100644 --- a/picard/tagger.py +++ b/picard/tagger.py @@ -1467,10 +1467,16 @@ def process_picard_args(): args.remote_commands_help = False args.processable = [] - for x in args.FILE_OR_URL: - if not urlparse(x).netloc: - x = os.path.abspath(x) - args.processable.append(f"LOAD {x}") + for path in args.FILE_OR_URL: + if not urlparse(path).netloc: + try: + path = os.path.abspath(path) + except FileNotFoundError: + # os.path.abspath raises if path is relative and cwd doesn't + # exist anymore. Just pass the path as it is and leave + # the error handling to Picard's file loading. + pass + args.processable.append(f"LOAD {path}") if args.exec: for e in args.exec: