Skip to content

Commit 265d45c

Browse files
ffontaineWenzel
authored andcommitted
Handle OSError exception
Handle OSError which can be returned by os.scandir Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
1 parent 64bc0db commit 265d45c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

checksec/__main__.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@
3030
def walk_filepath_list(filepath_list: List[Path], recursive: bool = False) -> Iterator[Path]:
3131
for path in filepath_list:
3232
if path.is_dir() and not path.is_symlink():
33-
if recursive:
34-
for f in os.scandir(path):
35-
yield from walk_filepath_list([Path(f)], recursive)
36-
else:
37-
yield from (Path(f) for f in os.scandir(path))
33+
try:
34+
if recursive:
35+
for f in os.scandir(path):
36+
yield from walk_filepath_list([Path(f)], recursive)
37+
else:
38+
yield from (Path(f) for f in os.scandir(path))
39+
except OSError:
40+
continue
3841
elif path.is_file():
3942
yield path
4043

0 commit comments

Comments
 (0)