Add patching getcwd/getcwdb for nt #894
Merged
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.
patch_open_code
doesn't seem to work in Python 3.12 #892 under WindowsTurns out that the fix for #892 actually worked, but with the concrete test code it failed under Windows in the CI because the current working dir was on another drive than C:.
The notation with a slash (or backslash) at the beginning of the path under Windows means that it uses the current drive. On creating the path, the current drive in the fake fs was used (which is C: by default) by calling
getcwd
in the fake fs, butimportlib.util.spec_from_file_location
usedos.fspath
that under Windows usesnt.getcwd
instead ofos.getcwd
, which was not patched.Patching
nt.getcwd
fixes this.Tasks