Skip to content

Commit

Permalink
Merge pull request #2676 from pypa/safe-venv-check
Browse files Browse the repository at this point in the history
Ignore OSError in is_virtual_environment check
  • Loading branch information
uranusjr committed Jul 30, 2018
2 parents ca7d5ac + a89acdc commit 63e1a40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/2676.bugfix
@@ -0,0 +1 @@
Prevent crashing when a virtual environment in ``WORKON_HOME`` is faulty.
8 changes: 6 additions & 2 deletions pipenv/utils.py
Expand Up @@ -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

Expand Down

0 comments on commit 63e1a40

Please sign in to comment.