New submission from Christian Heimes:

While I was testing #16499 I found a small bug in the venv code of the site 
module. The code in site.venv() doesn't use abspath() to sanitize the path to 
executable_dir. This leads to wrong behavior when a venv is created in the root 
of a hg checkout and the non-venv interpreter is called with a relative path:

(venv) heimes@hamiller:~/dev/python/cpython/venv$ ../python -c "import sys; 
['', '/usr/local/lib/', '/home/heimes/dev/python/cpython/Lib', 

The fix is simple, straight forward and totally harmless:
--- a/Lib/
+++ b/Lib/
@@ -484,7 +484,7 @@
         executable = os.environ['__PYVENV_LAUNCHER__']
         executable = sys.executable
-    executable_dir, executable_name = os.path.split(executable)
+    executable_dir, executable_name = 
     site_prefix = os.path.dirname(executable_dir)
     sys._home = None
     if sys.platform == 'win32':

components: Interpreter Core
messages: 176043
nosy: christian.heimes
priority: normal
severity: normal
status: open
title: site.venv() should use abspath(executable)
type: behavior
versions: Python 3.3, Python 3.4

Python tracker <>
Python-bugs-list mailing list

Reply via email to