@@ -264,22 +264,19 @@ def _safer_popen_windows(
264
264
creationflags = subprocess .CREATE_NO_WINDOW | subprocess .CREATE_NEW_PROCESS_GROUP
265
265
266
266
# When using a shell, the shell is the direct subprocess, so the variable must
267
- # be set in its environment, to affect its search behavior. (The "1" can be any
268
- # value.)
267
+ # be set in its environment, to affect its search behavior.
269
268
if shell :
270
- # The original may be immutable or reused by the caller. Make changes in a
271
- # copy.
269
+ # The original may be immutable, or the caller may reuse it. Mutate a copy.
272
270
env = {} if env is None else dict (env )
273
- env ["NoDefaultCurrentDirectoryInExePath" ] = "1"
271
+ env ["NoDefaultCurrentDirectoryInExePath" ] = "1" # The "1" can be an value.
274
272
275
273
# When not using a shell, the current process does the search in a
276
274
# CreateProcessW API call, so the variable must be set in our environment. With
277
- # a shell, this is unnecessary, in versions where
278
- # https://github.com/python/cpython/issues/101283 is patched. If that is
279
- # unpatched, then in the rare case the ComSpec environment variable is unset,
280
- # the search for the shell itself is unsafe. Setting
281
- # NoDefaultCurrentDirectoryInExePath in all cases, as is done here, is simpler
282
- # and protects against that. (As above, the "1" can be any value.)
275
+ # a shell, that's unnecessary if https://github.com/python/cpython/issues/101283
276
+ # is patched. In Python versions where it is unpatched, and in the rare case the
277
+ # ComSpec environment variable is unset, the search for the shell itself is
278
+ # unsafe. Setting NoDefaultCurrentDirectoryInExePath in all cases, as done here,
279
+ # is simpler and protects against that. (As above, the "1" can be any value.)
283
280
with patch_env ("NoDefaultCurrentDirectoryInExePath" , "1" ):
284
281
return Popen (
285
282
command ,
0 commit comments