From 835e329883faa82623e8155b66bbaa6223662dc1 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 25 Apr 2018 09:27:57 +0200 Subject: [PATCH] Some improvements for the virtualenv patch --- pythonx/jedi_vim.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pythonx/jedi_vim.py b/pythonx/jedi_vim.py index 5bcef0c..dc5154f 100644 --- a/pythonx/jedi_vim.py +++ b/pythonx/jedi_vim.py @@ -26,11 +26,12 @@ else: try: + # Somehow sys.prefix is set in combination with VIM and virtualenvs. + # However the sys path is not affected. Just reset it to the normal value. sys.prefix = sys.base_prefix sys.exec_prefix = sys.base_exec_prefix except AttributeError: - # Somehow sys.prefix is set in combination with VIM and virtualenvs. - # However the sys path is not affected. Just reset it to the normal value. + # If we're not in a virtualenv we don't care. Everything is fine. pass @@ -164,7 +165,7 @@ def get_environment(): global last_force_python_error force_python_version = vim_eval("g:jedi#force_py_version") - environment = jedi.api.environment.get_cached_default_environment() + environment = None if force_python_version != "auto": if '0000' in force_python_version or '9999' in force_python_version: # It's probably a float that wasn't shortened. @@ -184,6 +185,9 @@ def get_environment(): % force_python_version ) last_force_python_error = force_python_version + + if environment is None: + environment = jedi.api.environment.get_cached_default_environment() return environment