Skip to content

Commit e421b48

Browse files
committed
Guard os.listdir() call with os.path.isdir()
1 parent 4e0ec81 commit e421b48

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cuda_bindings/cuda/bindings/_internal/nvjitlink_linux.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ cdef void* load_library(const int driver_ver) except* with gil:
9292
attachment = []
9393
for so_dirname in candidate_so_dirs:
9494
attachment.append(f" listdir({repr(so_dirname)}):")
95-
for node in sorted(os.listdir(so_dirname)):
96-
attachment.append(f" {node}")
95+
if not os.path.isdir(so_dirname):
96+
attachment.append(" DIRECTORY DOES NOT EXIST")
97+
else:
98+
for node in sorted(os.listdir(so_dirname)):
99+
attachment.append(f" {node}")
97100
attachment = "\n".join(attachment)
98101
raise RuntimeError(f"Unable to load {so_basename} from: {', '.join(error_messages)}\n{attachment}")
99102

0 commit comments

Comments
 (0)