Skip to content

Commit 84bf2ca

Browse files
committed
Read USE_SHELL in Git.execute without DeprecationWarning
This changes how Git.execute itself accesses the USE_SHELL attribute, so that its own read of it does not issue a warning.
1 parent c5d5b16 commit 84bf2ca

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: git/cmd.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,12 @@ def execute(
11891189

11901190
stdout_sink = PIPE if with_stdout else getattr(subprocess, "DEVNULL", None) or open(os.devnull, "wb")
11911191
if shell is None:
1192-
shell = self.USE_SHELL
1192+
# Get the value of USE_SHELL with no deprecation warning. Do this without
1193+
# warnings.catch_warnings, to avoid a race condition with application code
1194+
# configuring warnings. The value could be looked up in type(self).__dict__
1195+
# or Git.__dict__, but those can break under some circumstances. This works
1196+
# the same as self.USE_SHELL in more situations; see Git.__getattribute__.
1197+
shell = super().__getattribute__("USE_SHELL")
11931198
_logger.debug(
11941199
"Popen(%s, cwd=%s, stdin=%s, shell=%s, universal_newlines=%s)",
11951200
redacted_command,

0 commit comments

Comments
 (0)