mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Make sure that you can select virtualenvs more precisely, fixes #1407
This commit is contained in:
@@ -261,25 +261,28 @@ def find_virtualenvs(paths=None, **kwargs):
|
||||
"""
|
||||
:param paths: A list of paths in your file system to be scanned for
|
||||
Virtualenvs. It will search in these paths and potentially execute the
|
||||
Python binaries. Also the VIRTUAL_ENV variable will be checked if it
|
||||
contains a valid Virtualenv. And CONDA_PREFIX will be checked to see
|
||||
if it contains a valid conda environment.
|
||||
Python binaries.
|
||||
:param safe: Default True. In case this is False, it will allow this
|
||||
function to execute potential `python` environments. An attacker might
|
||||
be able to drop an executable in a path this function is searching by
|
||||
default. If the executable has not been installed by root, it will not
|
||||
be executed.
|
||||
:param use_environment_vars: Default True. If True, the VIRTUAL_ENV
|
||||
variable will be checked if it contains a valid VirtualEnv.
|
||||
CONDA_PREFIX will be checked to see if it contains a valid conda
|
||||
environment.
|
||||
|
||||
:yields: :class:`Environment`
|
||||
"""
|
||||
def py27_comp(paths=None, safe=True):
|
||||
def py27_comp(paths=None, safe=True, use_environment_vars=True):
|
||||
if paths is None:
|
||||
paths = []
|
||||
|
||||
_used_paths = set()
|
||||
|
||||
# Using this variable should be safe, because attackers might be able
|
||||
# to drop files (via git) but not environment variables.
|
||||
if use_environment_vars:
|
||||
# Using this variable should be safe, because attackers might be
|
||||
# able to drop files (via git) but not environment variables.
|
||||
virtual_env = _get_virtual_env_from_var()
|
||||
if virtual_env is not None:
|
||||
yield virtual_env
|
||||
|
||||
Reference in New Issue
Block a user