From 645ec068c13388ff2493d99b5e54b9e33b7909ac Mon Sep 17 00:00:00 2001 From: John Fultz Date: Thu, 17 Dec 2015 19:03:10 -0600 Subject: [PATCH] Fix error invoking git which happens on all of my Windows systems. Trying to invoke git always throws the following error to my console: OSError: [WinError 6] The handle is invalid Populating stdin/stderr with subprocess.PIPE fixes the problem. I think this is the following Python bug: https://bugs.python.org/issue3905 --- modules/util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/util.py b/modules/util.py index 2d785cc..90b3f12 100644 --- a/modules/util.py +++ b/modules/util.py @@ -4,17 +4,21 @@ def execute_command(command, working_dir=None): startupinfo = None + stdpipe = None # hide console window on windows if os.name == 'nt': startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + stdpipe = subprocess.PIPE output = None try: output = subprocess.check_output( command, cwd=working_dir, - startupinfo=startupinfo + startupinfo=startupinfo, + stdin=stdpipe, + stderr=stdpipe ) except (subprocess.CalledProcessError, AttributeError): # Git will return an error when the given directory