← 返回首页
Read USE_SHELL in Git.execute without DeprecationWarning · gitpython-developers/GitPython@84bf2ca · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

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

Provide feedback

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

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

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

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎git/cmd.py‎

Lines changed: 6 additions & 1 deletion
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)

Footer

© 2026 GitHub, Inc.