Skip to content

site.venv() should use abspath(executable) #60723

Description

@tiran
BPO 16519
Nosy @vsajip, @tiran, @merwok

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2012-11-23.19:22:49.488>
created_at = <Date 2012-11-21.07:58:54.232>
labels = ['interpreter-core', 'type-bug']
title = 'site.venv() should use abspath(executable)'
updated_at = <Date 2012-11-23.19:22:49.486>
user = 'https://github.com/tiran'

bugs.python.org fields:

activity = <Date 2012-11-23.19:22:49.486>
actor = 'python-dev'
assignee = 'none'
closed = True
closed_date = <Date 2012-11-23.19:22:49.488>
closer = 'python-dev'
components = ['Interpreter Core']
creation = <Date 2012-11-21.07:58:54.232>
creator = 'christian.heimes'
dependencies = []
files = []
hgrepos = []
issue_num = 16519
keywords = []
message_count = 2.0
messages = ['176043', '176219']
nosy_count = 4.0
nosy_names = ['vinay.sajip', 'christian.heimes', 'eric.araujo', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue16519'
versions = ['Python 3.3', 'Python 3.4']

Activity

  1. tiran commented on Nov 21, 2012

    @tiran
    MemberAuthor

    While I was testing bpo-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; print(sys.path)"
    ['', '/usr/local/lib/python34.zip', '/home/heimes/dev/python/cpython/Lib', '/home/heimes/dev/python/cpython/Lib/plat-linux', '/home/heimes/dev/python/cpython/build/lib.linux-x86_64-3.4-pydebug', '/home/heimes/dev/python/cpython/venv/lib/python3.4/site-packages']

    The fix is simple, straight forward and totally harmless:
    --- a/Lib/site.py
    +++ b/Lib/site.py
    @@ -484,7 +484,7 @@
             executable = os.environ['__PYVENV_LAUNCHER__']
         else:
             executable = sys.executable
    -    executable_dir, executable_name = os.path.split(executable)
    +    executable_dir, executable_name = os.path.split(os.path.abspath(executable))
         site_prefix = os.path.dirname(executable_dir)
         sys._home = None
         if sys.platform == 'win32':
  2. added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    type-bugAn unexpected behavior, bug, or error
    on Nov 21, 2012
  3. python-dev commented on Nov 23, 2012

    python-devmannequin
    Mannequin

    New changeset fe2200c1c2d3 by Vinay Sajip in branch '3.3':
    Issue bpo-16519: Used os.path.abspath, removed unnecessary code for executable_name.
    http://hg.python.org/cpython/rev/fe2200c1c2d3

    New changeset a874c4a6ad5f by Vinay Sajip in branch 'default':
    Closes bpo-16519: Merged fix from 3.3.
    http://hg.python.org/cpython/rev/a874c4a6ad5f

  4. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions