summaryrefslogtreecommitdiff
path: root/virtualenv.py
diff options
context:
space:
mode:
authorPaul Nasrat <pnasrat@gmail.com>2011-04-21 11:10:11 +0100
committerPaul Nasrat <pnasrat@gmail.com>2011-04-21 15:31:17 +0100
commit5d57c4cb78fb9ba17027deadbafdda01efea12e1 (patch)
treec93b649f9bde07ec165e018bb26695824563f79e /virtualenv.py
parente48487561417f81ba232a3016572e7aaecc67248 (diff)
downloadvirtualenv-5d57c4cb78fb9ba17027deadbafdda01efea12e1.tar.gz
Prevent traceback with non-exec interpreter
Fixes #121 Add tests for virtualenv with nose and mock Add helper method to virtualenv for is_executable Raise SystemExit rather than sys.exit directly Tested on 2.4.4, 2.7.1 and 3.2
Diffstat (limited to 'virtualenv.py')
-rwxr-xr-xvirtualenv.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/virtualenv.py b/virtualenv.py
index f49f3a3..5bd5534 100755
--- a/virtualenv.py
+++ b/virtualenv.py
@@ -1228,9 +1228,16 @@ def resolve_interpreter(exe):
break
if not os.path.exists(exe):
logger.fatal('The executable %s (from --python=%s) does not exist' % (exe, exe))
- sys.exit(3)
+ raise SystemExit(3)
+ if not is_executable(exe):
+ logger.fatal('The executable %s (from --python=%s) is not executable' % (exe, exe))
+ raise SystemExit(3)
return exe
+def is_executable(exe):
+ """Checks a file is executable"""
+ return os.access(exe, os.X_OK)
+
############################################################
## Relocating the environment: