reuse of closed sys.stdout in service log output is to be prevented #15747
+18
−50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User description
Reference Fixes #15629
@cgoldberg
In the given pr it improves error handling and robustness in the Service class by adding a pre-check before starting the subprocess:
Checks if the executable_path exists and is executable using os.path.isfile() and os.access().
Raises a clear WebDriverException with helpful messages if the path is invalid or lacks execution permissions.
Prevents cryptic or low-level errors when the executable is missing or misconfigured.
Fixes an IndentationError in _start_process caused by missing indentation.
PR Type
Bug fix, Tests
Description
Prevents reuse of closed sys.stdout in Service log output
Adds pre-check for executable path existence and permissions
Improves error handling with clear WebDriverException messages
Adds regression test for closed stdout reuse scenario
Changes walkthrough 📝
service.py
Add executable path validation and error handling in Service
py/selenium/webdriver/common/service.py
test_service.py
Add regression test for closed stdout reuse in Service
py/test/selenium/webdriver/common/test_service.py