Skip to content

Commit

Permalink
Read USE_SHELL in Git.execute without DeprecationWarning
Browse files Browse the repository at this point in the history
This changes how Git.execute itself accesses the USE_SHELL
attribute, so that its own read of it does not issue a warning.
  • Loading branch information
EliahKagan committed Mar 29, 2024
1 parent c5d5b16 commit 84bf2ca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,12 @@ def execute(

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

0 comments on commit 84bf2ca

Please sign in to comment.