Skip to content

Restore the working directory after nested Path contexts - #256

Closed
vitalivo wants to merge 1 commit into
jaraco:mainfrom
vitalivo:fix/reentrant-directory-context
Closed

vitalivo wants to merge 1 commit into
jaraco:mainfrom
vitalivo:fix/reentrant-directory-context

Conversation

@vitalivo

Copy link
Copy Markdown

Nesting with directory: twice with the same Path instance overwrites the saved working directory. The outer context then leaves the process in directory instead of restoring its original location.

Keep a stack of previous directories, pushing only after chdir succeeds and popping on exit. Adds normal-exit and exception-unwinding regressions, plus a changelog fragment.

Both regressions fail before the change. Validation: 144 tests/doctests passed, 1 skipped on Python 3.10 and 3.14. Changed files pass Ruff formatting, and Ruff check introduces no diagnostics compared with the base revision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant