| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…t environment shutil.which() only inserts the current directory into the search path when _winapi.NeedCurrentDirectoryForExePath() returns true, and that consults the NoDefaultCurrentDirectoryInExePath environment variable. On a machine where that variable is set, TestWhich.test_environ_path_cwd and TestWhichBytes.test_environ_path_cwd failed because which() correctly declined to search the current directory. Unset the variable inside the EnvironmentVarGuard the test already uses, so an ambient value cannot change what the test exercises.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead. |
Sorry, something went wrong.
|
The following commit authors need to sign the Contributor License Agreement: |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
TestWhich.test_environ_path_cwd and TestWhichBytes.test_environ_path_cwd
fail on Windows when NoDefaultCurrentDirectoryInExePath is set in the
environment the test suite runs in.
The test clears PATH so that shutil.which() falls back to the current
directory, then asserts the result is .\<file>. But shutil.which() only
inserts the current directory into the search path when
_win_path_needs_curdir() returns true, which delegates to
_winapi.NeedCurrentDirectoryForExePath(). That API consults
NoDefaultCurrentDirectoryInExePath, so when the variable is present
which() correctly declines to search the current directory and the
assertion fails.
The test already opens an os_helper.EnvironmentVarGuard to set PATH;
this unsets NoDefaultCurrentDirectoryInExePath in the same guard so the
ambient environment cannot change what the test exercises.
TestWhich.test_win_path_needs_curdir in the same class already accounts
for this mechanism by patching _winapi.NeedCurrentDirectoryForExePath.
Verified on Windows 11, main at 04242c0:
No behaviour change to shutil; test-only.