Skip to content

Commit b9d9e56

Browse files
committed
Further improve _safer_popen_windows doc
This adjusts the formatting of the _safer_popen_windows docstring and comments, and rewords some parts for clarity and brevity.
1 parent ad8190b commit b9d9e56

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

git/cmd.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -264,22 +264,19 @@ def _safer_popen_windows(
264264
creationflags = subprocess.CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP
265265

266266
# 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.
269268
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.
272270
env = {} if env is None else dict(env)
273-
env["NoDefaultCurrentDirectoryInExePath"] = "1"
271+
env["NoDefaultCurrentDirectoryInExePath"] = "1" # The "1" can be an value.
274272

275273
# When not using a shell, the current process does the search in a
276274
# 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.)
283280
with patch_env("NoDefaultCurrentDirectoryInExePath", "1"):
284281
return Popen(
285282
command,

0 commit comments

Comments
 (0)