From 24bbcf8811aea46caefc8a1371fa9ca49ade8932 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Thu, 11 Sep 2014 15:19:26 -0700 Subject: [PATCH] Fix KeyError on no 'no_proxy' env var --- python/ycm/youcompleteme.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/ycm/youcompleteme.py b/python/ycm/youcompleteme.py index 2f9c9153..54da2cd7 100644 --- a/python/ycm/youcompleteme.py +++ b/python/ycm/youcompleteme.py @@ -46,6 +46,12 @@ try: except ImportError: USE_ULTISNIPS_DATA = False +def PatchNoProxy(): + current_value = os.environ.get('no_proxy', '') + additions = '127.0.0.1,localhost' + os.environ['no_proxy'] = ( additions if not current_value + else current_value + ',' + additions ) + # We need this so that Requests doesn't end up using the local HTTP proxy when # talking to ycmd. Users should actually be setting this themselves when # configuring a proxy server on their machine, but most don't know they need to @@ -53,7 +59,7 @@ except ImportError: # Relevant issues: # https://github.com/Valloric/YouCompleteMe/issues/641 # https://github.com/kennethreitz/requests/issues/879 -os.environ['no_proxy'] = os.environ['no_proxy'] + (',' if len (os.environ['no_proxy']) > 0 else '') + '127.0.0.1,localhost' +PatchNoProxy() # Force the Python interpreter embedded in Vim (in which we are running) to # ignore the SIGINT signal. This helps reduce the fallout of a user pressing