Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd2506c7

Browse files
committed
Make Git.execute a bit simpler and very slightly more robust
This covers the rare unpatchedpython/cpython#101283 case theprevious commit added tests for, that only applies in the unusualsituation that the ComSpec environment variable is unset and an oldbuild (but this includes downloadable builds and currentactions/setup-python builds) of Python <=3.9 for Windows is in use.The main benefit of this change is really to slightly simplify thecode under test. (It might even be justified to remove theuse_shell_impostor=True test cases at some point.)
1 parent865c6e8 commitd2506c7

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

‎git/cmd.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -988,25 +988,22 @@ def execute(
988988
ifshellisNone:
989989
shell=self.USE_SHELL
990990

991-
cmd_not_found_exception=FileNotFoundError
992-
maybe_patch_caller_env=contextlib.nullcontext()
993-
994991
ifos.name=="nt":
992+
cmd_not_found_exception=OSError
995993
ifkill_after_timeoutisnotNone:
996994
raiseGitCommandError(
997995
redacted_command,
998996
'"kill_after_timeout" feature is not supported on Windows.',
999997
)
1000-
1001-
cmd_not_found_exception=OSError
1002-
1003-
# Search PATH, but do not search CWD. The "1" can be any value.
998+
# Search PATH but not CWD. The "1" can be any value. We'll patch just before
999+
# the Popen call and unpatch just after, or we get a worse race condition.
1000+
maybe_patch_caller_env=patch_env("NoDefaultCurrentDirectoryInExePath","1")
10041001
ifshell:
1005-
#If the directsubprocess is ashell, this must go in its environment.
1002+
#Modify the direct shell subprocess's own search behavior accordingly.
10061003
env["NoDefaultCurrentDirectoryInExePath"]="1"
1007-
else:
1008-
# If we're not using a shell, the variable goes in our own environment.
1009-
maybe_patch_caller_env=patch_env("NoDefaultCurrentDirectoryInExePath","1")
1004+
else:
1005+
cmd_not_found_exception=FileNotFoundError
1006+
maybe_patch_caller_env=contextlib.nullcontext()
10101007
# END handle
10111008

10121009
stdout_sink=PIPEifwith_stdoutelsegetattr(subprocess,"DEVNULL",None)oropen(os.devnull,"wb")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp