Skip to content
Prev Previous commit
Next Next commit
creationflags must be set to 0 on non-windows platforms
  • Loading branch information
barry-scott committed Aug 1, 2016
commit 572ebd6e92cca39100183db7bbeb6b724dde0211
9 changes: 5 additions & 4 deletions git/cmd.py
Original file line number Diff line number Diff line change
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 @@ -610,10 +613,9 @@ def execute(self, command,

try:
if sys.platform == 'win32':
Copy link
Member

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

CREATE_NO_WINDOW = 0x08000000
creationflags = CREATE_NO_WINDOW
else:
creationflags = None
creationflags = 0

proc = Popen(command,
env=env,
Expand All @@ -637,10 +639,9 @@ def execute(self, command,
def _kill_process(pid):
""" Callback method to kill a process. """
if sys.platform == 'win32':
CREATE_NO_WINDOW = 0x08000000
creationflags = CREATE_NO_WINDOW
else:
creationflags = None
creationflags = 0

p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags=creationflags)
child_pids = []
Expand Down