From 58b833ab9a7f6122cf0d147f9f6ebe43ae354acf Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Mon, 18 Dec 2023 14:41:59 +0000 Subject: [PATCH 1/2] use subprocess.DEVNULL instead of open(os.devnull) to avoid leaking a file handle --- py/selenium/webdriver/firefox/firefox_binary.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/selenium/webdriver/firefox/firefox_binary.py b/py/selenium/webdriver/firefox/firefox_binary.py index 758e1677b5c8d..2a97f5309266f 100644 --- a/py/selenium/webdriver/firefox/firefox_binary.py +++ b/py/selenium/webdriver/firefox/firefox_binary.py @@ -19,7 +19,7 @@ import os import time from platform import system -from subprocess import STDOUT +from subprocess import STDOUT, DEVNULL from subprocess import Popen from selenium.common.exceptions import WebDriverException @@ -41,7 +41,7 @@ def __init__(self, firefox_path=None, log_file=None): self._start_cmd = firefox_path # We used to default to subprocess.PIPE instead of /dev/null, but after # a while the pipe would fill up and Firefox would freeze. - self._log_file = log_file or open(os.devnull, "wb") + self._log_file = log_file or DEVNULL self.command_line = None self.platform = system().lower() if not self._start_cmd: From c26eea4c256ce59cc5303e81c0df8fe37fd81250 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 19 Dec 2023 09:29:45 +0000 Subject: [PATCH 2/2] Update py/selenium/webdriver/firefox/firefox_binary.py --- py/selenium/webdriver/firefox/firefox_binary.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py/selenium/webdriver/firefox/firefox_binary.py b/py/selenium/webdriver/firefox/firefox_binary.py index 2a97f5309266f..707d7421a1231 100644 --- a/py/selenium/webdriver/firefox/firefox_binary.py +++ b/py/selenium/webdriver/firefox/firefox_binary.py @@ -19,7 +19,8 @@ import os import time from platform import system -from subprocess import STDOUT, DEVNULL +from subprocess import DEVNULL +from subprocess import STDOUT from subprocess import Popen from selenium.common.exceptions import WebDriverException