From 236a6c4522128b51e456ff1ac1062dd5c490fc8a Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Mon, 30 Jul 2018 15:37:10 +0800 Subject: [PATCH 1/2] Ignore OSError in is_virtual_environment check This works around a faulty virtual environment on my machine that makes os.access throw "OSError: too many level of symlinks". If a virtual environment is faulty, we can just ignore it. --- pipenv/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pipenv/utils.py b/pipenv/utils.py index 9cf62366d1..d07d36abcf 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -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 From a89acdc589a19ddab730cff40a9f62768aaa6476 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Mon, 30 Jul 2018 15:41:25 +0800 Subject: [PATCH 2/2] News --- news/2676.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/2676.bugfix diff --git a/news/2676.bugfix b/news/2676.bugfix new file mode 100644 index 0000000000..fb47d64b25 --- /dev/null +++ b/news/2676.bugfix @@ -0,0 +1 @@ +Prevent crashing when a virtual environment in ``WORKON_HOME`` is faulty.