diff --git a/python/ycm/utils.py b/python/ycm/utils.py index 5e7058ed..a36493b0 100644 --- a/python/ycm/utils.py +++ b/python/ycm/utils.py @@ -171,17 +171,13 @@ def ForceSemanticCompletion( request_data ): return ( 'force_semantic' in request_data and bool( request_data[ 'force_semantic' ] ) ) -def SafePopen( args, bufsize = 0, executable = None, stdin = None, - stdout = None, stderr = None, preexec_fn = None, - close_fds = False, shell = False, cwd = None, env = None, - universal_newlines = False, startupinfo = None, - creationflags = 0 ): - if stdin is None: + +# A wrapper for subprocess.Popen that works around a Popen bug on Windows. +def SafePopen( *args, **kwargs ): + if kwargs.get( 'stdin', '' ) is None: # We need this on Windows otherwise bad things happen. See issue #637. - stdin = subprocess.PIPE if OnWindows() else None + kwargs[ 'stdin' ] = subprocess.PIPE if OnWindows() else None - return subprocess.Popen( args, bufsize, executable, stdin, stdout, stderr, - preexec_fn, close_fds, shell, cwd, env, - universal_newlines, startupinfo, creationflags ) + return subprocess.Popen( *args, **kwargs )