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

Commit05de5c0

Browse files
committed
Implement instance USE_SHELL lookup in __getattr__
This is with the intention of making it so that Git.USE_SHELL isunittest.mock.patch patchable. However, while this moves in theright direction, it can't be done this way, as the attribute isfound to be absent on the class, so when unittest.mock.patchunpatches, it tries to delete the attribute it has set, whichfails due to the metaclass's USE_SHELL instance property having nodeleter.
1 parentd38e721 commit05de5c0

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

‎git/cmd.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -399,28 +399,25 @@ def __setstate__(self, d: Dict[str, Any]) -> None:
399399

400400
_USE_SHELL:bool=False
401401

402-
@property
403-
defUSE_SHELL(self)->bool:
404-
"""Deprecated. If set to ``True``, a shell will be used to execute git commands.
402+
USE_SHELL:bool
403+
"""Deprecated. If set to ``True``, a shell will be used to execute git commands.
405404
406-
Prior to GitPython 2.0.8, this had a narrow purpose in suppressing console
407-
windowsin graphical Windows applications. In 2.0.8 and higher, it provides no
408-
benefit, asGitPython solves that problem more robustly and safely by using the
409-
``CREATE_NO_WINDOW`` process creation flag on Windows.
405+
Prior to GitPython 2.0.8, this had a narrow purpose in suppressing console windows
406+
in graphical Windows applications. In 2.0.8 and higher, it provides no benefit, as
407+
GitPython solves that problem more robustly and safely by using the
408+
``CREATE_NO_WINDOW`` process creation flag on Windows.
410409
411-
Code that uses ``USE_SHELL = True`` or that passes ``shell=True`` to any
412-
GitPythonfunctions should be updated to use the default value of ``False``
413-
instead. ``True``is unsafe unless the effect of shell expansions is fully
414-
considered and accountedfor, which is not possible under most circumstances.
410+
Code that uses ``USE_SHELL = True`` or that passes ``shell=True`` to any GitPython
411+
functions should be updated to use the default value of ``False`` instead. ``True``
412+
is unsafe unless the effect of shell expansions is fully considered and accounted
413+
for, which is not possible under most circumstances.
415414
416-
See:
415+
See:
417416
418-
- :meth:`Git.execute` (on the ``shell`` parameter).
419-
- https://github.com/gitpython-developers/GitPython/commit/0d9390866f9ce42870d3116094cd49e0019a970a
420-
- https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags
421-
"""
422-
_warn_use_shell(False)
423-
returnself._USE_SHELL
417+
- :meth:`Git.execute` (on the ``shell`` parameter).
418+
- https://github.com/gitpython-developers/GitPython/commit/0d9390866f9ce42870d3116094cd49e0019a970a
419+
- https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags
420+
"""
424421

425422
_git_exec_env_var="GIT_PYTHON_GIT_EXECUTABLE"
426423
_refresh_env_var="GIT_PYTHON_REFRESH"
@@ -921,6 +918,11 @@ def __getattr__(self, name: str) -> Any:
921918
"""
922919
ifname.startswith("_"):
923920
returnsuper().__getattribute__(name)
921+
922+
ifname=="USE_SHELL":
923+
_warn_use_shell(False)
924+
returnself._USE_SHELL
925+
924926
returnlambda*args,**kwargs:self._call_process(name,*args,**kwargs)
925927

926928
defset_persistent_git_options(self,**kwargs:Any)->None:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp