Repository navigation
Report cwd failures to the parent process - #86
Open
Zhuyuyangyy wants to merge 2 commits into
Open
Zhuyuyangyy wants to merge 2 commits into
Zhuyuyangyy wants to merge 2 commits into
Conversation
Include chdir in the existing OSError reporting boundary while preserving preexec_fn ordering.
Use isolated interpreters for invalid cwd regressions, and retain a valid cwd/preexec control.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related to pexpect/pexpect#757.
os.chdir(cwd)runs in the forked child outside the existingOSErrorreporting boundary. If the directory is missing or is a regular file, the child-side exception can escape into the caller's Python code while the parent receives aPtyProcessas though startup succeeded. In interactive use, this can leave the parent waiting for the child to exec.Include the directory change in the existing error-pipe boundary, retaining the current order of
chdir,preexec_fn, andexec. Reuse the existingOSError/errno protocol rather than prechecking the path in the parent.The new tests run invalid-cwd calls in isolated interpreters so that a broken forked child cannot resume the test suite. They cover a missing directory, a regular file used as cwd, and a valid directory with
preexec_fnrunning after the directory change and without changing the parent's cwd.Validation on Linux / Python 3.12.3:
12d3221806c0a7cf114b894101814b1f9e338ed4:python3 -m unittest tests.test_cwd -v— 2 expected regression failures, 1 valid-cwd control passed.python3 -m unittest discover -v— all 18 tests passed.python3 -m compileall -q ptyprocess tests/test_cwd.py— passed.git diff --check— passed.Other Python versions and operating systems were not tested. This is a dependency-level fix; it does not itself publish a new ptyprocess release or change pexpect's dependency requirements.
AI-assisted investigation, implementation, tests, review, and PR description. No independent human review is claimed.