◐ Shell
clean mode source ↗

FIx issue #464 corrupt log file by barry-scott · Pull Request #469 · gitpython-developers/GitPython

Expand Up @@ -43,6 +43,9 @@ safe_decode, )
# value of Windows process creation flag taken from MSDN CREATE_NO_WINDOW = 0x08000000
execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output', 'with_exceptions', 'as_process', 'stdout_as_string', 'output_stream', 'with_stdout', 'kill_after_timeout', Expand Down Expand Up @@ -609,6 +612,11 @@ def execute(self, command, # end handle
try: if sys.platform == 'win32':

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally for these kinds of assignment, I believe it's easier to read by starting out like this:

creationflags = None
if sys.platform == 'win32':
    creationflags = CREATE_NO_WINDOW
creationflags = CREATE_NO_WINDOW else: creationflags = 0
proc = Popen(command, env=env, cwd=cwd, Expand All @@ -619,6 +627,7 @@ def execute(self, command, shell=self.USE_SHELL, close_fds=(os.name == 'posix'), # unsupported on windows universal_newlines=universal_newlines, creationflags=creationflags, **subprocess_kwargs ) except cmd_not_found_exception as err: Expand All @@ -629,7 +638,12 @@ def execute(self, command,
def _kill_process(pid): """ Callback method to kill a process. """ p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE) if sys.platform == 'win32': creationflags = CREATE_NO_WINDOW else: creationflags = 0
p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags=creationflags) child_pids = [] for line in p.stdout: if len(line.split()) > 0: Expand Down