Skip to content

Commit fb67992

Browse files
mikedep333claude
authored andcommitted
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 <mikedep333@redhat.com> Co-Authored-By: Claude Opus 4.6 <claude@anthropic.com> Signed-off-by: pmattsso <pmattsso@redhat.com>
1 parent aec9c9c commit fb67992

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/fromager/sources.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,10 @@ def scan_compiled_extensions(
865865
logger.debug("file %s has a binary extension suffix", relpath)
866866
issues.append(relpath)
867867
elif suffix not in ignore_suffixes:
868+
# Path.walk() lists symlinks to directories as filenames
869+
# rather than dirnames, causing IsADirectoryError on open().
870+
if not filepath.is_file():
871+
continue
868872
with filepath.open("rb") as f:
869873
header = f.read(_MAGIC_HEADERS_READ)
870874
if header.startswith(magic_headers):

0 commit comments

Comments
 (0)