Skip to content

Commit ac268a1

Browse files
authored
[py]: Handle error cases for pathlib is_file - fixes #12474
1 parent 20fb45b commit ac268a1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

py/selenium/webdriver/remote/file_detector.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from abc import ABCMeta
1919
from abc import abstractmethod
20+
from contextlib import suppress
2021
from pathlib import Path
2122
from typing import Optional
2223

@@ -45,5 +46,6 @@ class LocalFileDetector(FileDetector):
4546

4647
def is_local_file(self, *keys: AnyKey) -> Optional[str]:
4748
file_path = "".join(keys_to_typing(keys))
48-
path = Path(file_path)
49-
return file_path if path.is_file() else None
49+
with suppress(OSError):
50+
return Path(file_path).is_file()
51+

0 commit comments

Comments
 (0)