Skip to content

Commit a093cfd

Browse files
change ValueError to FileNotFoundError
1 parent 149f169 commit a093cfd

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

kernel_tuner/util.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,8 @@ def get_kernel_string(kernel_source, params=None):
520520
kernel_string = read_file(kernel_source)
521521
elif isinstance(kernel_source, str):
522522
if looks_like_a_filename(kernel_source):
523-
kernel_string = read_file(kernel_source)
524-
if kernel_string is None:
525-
raise ValueError(f"{kernel_source} looks like a filename, but cannot open file")
523+
with open(kernel_source, "r") as f:
524+
kernel_string = f.read()
526525
else:
527526
kernel_string = kernel_source
528527
else:

test/test_util_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def test_get_kernel_string_filename_not_found():
527527
# when the string looks like a filename, but the file does not exist
528528
# check if throws an exception
529529
bogus_filename = "filename_3456789.cu"
530-
with pytest.raises(ValueError):
530+
with pytest.raises(FileNotFoundError):
531531
get_kernel_string(bogus_filename)
532532

533533

0 commit comments

Comments
 (0)