From 7a3be9ba932a5e6c1a478a0cf737f73a1bea54fd Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Mon, 13 Nov 2023 19:22:12 +0000 Subject: [PATCH] Avoid FileNotFoundError if FILENAME does not exist File ".../linkcheck/fileutil.py", line 110, in is_valid_config_source return os.path.isfile(filename) or stat.S_ISFIFO(os.stat(filename).st_mode) ^^^^^^^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory --- linkcheck/fileutil.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linkcheck/fileutil.py b/linkcheck/fileutil.py index db574500..22572ec1 100644 --- a/linkcheck/fileutil.py +++ b/linkcheck/fileutil.py @@ -107,4 +107,5 @@ def is_writable_by_others(filename): def is_valid_config_source(filename): """Check if the file is a valid config file.""" - return os.path.isfile(filename) or stat.S_ISFIFO(os.stat(filename).st_mode) + return os.path.exists(filename) and ( + os.path.isfile(filename) or stat.S_ISFIFO(os.stat(filename).st_mode))