Skip to content

Commit

Permalink
Fixing issues with libs printing to stdout
Browse files Browse the repository at this point in the history
Details in source comment.
  • Loading branch information
Valloric committed Feb 20, 2016
1 parent a5f16b1 commit b45d703
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ycmd/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,15 @@ def CloseStdin():
def Main():
args = ParseArguments()

# Need to open these files in binary mode because of bytes vs unicode. If we
# open in text mode (default), then third-party code that uses `print` (we're
# replacing sys.stdout!) with an `str` object on py2 will cause tracebacks
# because text mode insists on unicode objects. (Don't forget, `open` is
# actually `io.open` because of future builtins.)
if args.stdout is not None:
sys.stdout = open( args.stdout, 'w' )
sys.stdout = open( args.stdout, 'wb' )
if args.stderr is not None:
sys.stderr = open( args.stderr, 'w' )
sys.stderr = open( args.stderr, 'wb' )

SetupLogging( args.log )
options, hmac_secret = SetupOptions( args.options_file )
Expand Down

0 comments on commit b45d703

Please sign in to comment.