Merge pull request #2676 from pypa/safe-venv-check

Ignore OSError in is_virtual_environment check
This commit is contained in:
Tzu-ping Chung
2018-07-30 15:59:10 +08:00
committed by GitHub
2 changed files with 7 additions and 2 deletions
+1
View File
@@ -0,0 +1 @@
Prevent crashing when a virtual environment in ``WORKON_HOME`` is faulty.
+6 -2
View File
@@ -1350,8 +1350,12 @@ def is_virtual_environment(path):
if not path.is_dir():
return False
for bindir_name in ('bin', 'Scripts'):
for python_like in path.joinpath(bindir_name).glob('python*'):
if python_like.is_file() and os.access(str(python_like), os.X_OK):
for python in path.joinpath(bindir_name).glob('python*'):
try:
exeness = python.is_file() and os.access(str(python), os.X_OK)
except OSError:
exeness = False
if exeness:
return True
return False