From fb67992d957e2cde703ea9aabdb3086d28056648 Mon Sep 17 00:00:00 2001 From: Mike DePaulo Date: Tue, 31 Mar 2026 16:54:45 -0400 Subject: [PATCH] fix(sources): skip non-regular files in scan_compiled_extensions pathlib.Path.walk() lists symlinks to directories as filenames rather than dirnames. This causes scan_compiled_extensions to attempt to open() them, resulting in IsADirectoryError. Add an is_file() check to skip non-regular files before attempting to read their contents. Closes: #1001 Closes: #1004 Co-Authored-By: Mike DePaulo Co-Authored-By: Claude Opus 4.6 Signed-off-by: pmattsso --- src/fromager/sources.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fromager/sources.py b/src/fromager/sources.py index 6e3c11c9..54f31bbe 100644 --- a/src/fromager/sources.py +++ b/src/fromager/sources.py @@ -865,6 +865,10 @@ def scan_compiled_extensions( logger.debug("file %s has a binary extension suffix", relpath) issues.append(relpath) elif suffix not in ignore_suffixes: + # Path.walk() lists symlinks to directories as filenames + # rather than dirnames, causing IsADirectoryError on open(). + if not filepath.is_file(): + continue with filepath.open("rb") as f: header = f.read(_MAGIC_HEADERS_READ) if header.startswith(magic_headers):