Commit 400d3bd
refactor(sources): use EAFP pattern instead of is_file() check
Replace the is_file() stat syscall with a try/except around open() to
handle symlinks to directories in scan_compiled_extensions. This avoids
an extra syscall per file, eliminates the TOCTOU race between the check
and the open, and is more idiomatic Python (EAFP over LBYL).
Only IsADirectoryError is caught to avoid masking real I/O errors.
Co-Authored-By: Claude Opus 4.6 <claude@anthropic.com>
Signed-off-by: Mike DePaulo <mikedep333@redhat.com>1 parent cd32d2e commit 400d3bd
1 file changed
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
867 | 867 | | |
868 | 868 | | |
869 | 869 | | |
870 | | - | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
871 | 874 | | |
872 | | - | |
873 | | - | |
874 | 875 | | |
875 | 876 | | |
876 | 877 | | |
| |||
0 commit comments