Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't leak a file descriptor to os.devnull by default #13162

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions py/selenium/webdriver/common/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def __init__(
) -> None:
if isinstance(log_output, str):
self.log_output = open(log_output, "a+", encoding="utf-8")
elif log_output is subprocess.STDOUT:
elif log_output == subprocess.STDOUT:
self.log_output = None
elif log_output is None or log_output is subprocess.DEVNULL:
self.log_output = open(os.devnull, "wb")
elif log_output is None or log_output == subprocess.DEVNULL:
self.log_output = subprocess.DEVNULL
else:
self.log_output = log_output

Expand Down Expand Up @@ -135,7 +135,7 @@ def send_remote_shutdown_command(self) -> None:
def stop(self) -> None:
"""Stops the service."""

if self.log_output != PIPE:
if self.log_output not in {PIPE, subprocess.DEVNULL}:
if isinstance(self.log_output, IOBase):
self.log_output.close()
elif isinstance(self.log_output, int):
Expand Down