This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: shebanged scripts can escape from `venv` depending on how it was created
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Anthony Sottile, vinay.sajip
Priority: normal Keywords: patch

Created on 2020-02-16 19:21 by Anthony Sottile, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19030 merged Anthony Sottile, 2020-03-16 18:40
Messages (2)
msg362095 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2020-02-16 19:21
This is distilled from a larger example to be small/silly, however this caused real problems

A script which was intended for python3.6 exactly was written as follows:

#!/usr/bin/env python3.6

when creating a virtualenv with `python3.6 -m venv venv36` you end up with `python` / `python3` / `python3.6` executables in the venv

however, when creating a virtualenv with `python3 -m venv venv36` you only end up with `python` / `python3` executables


using `-mvirtualenv` (pypa/virtualenv) instead of venv, all three are reliably created


the fix is fairly straightforward, adding `f'python3.{sys.version_info[0]}'` to this tuple:
msg364389 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2020-03-17 07:29
New changeset 58ec58a42bece5b2804b178c7a6a7e67328465db by Anthony Sottile in branch 'master':
bpo-39656: Ensure `bin/python3.#` is always present in virtual environments on POSIX (GH-19030)
Date User Action Args
2022-04-11 14:59:26adminsetgithub: 83837
2020-04-27 07:37:57ned.deilylinkissue32444 superseder
2020-03-19 11:20:59vinay.sajipsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-03-17 07:29:17vinay.sajipsetnosy: + vinay.sajip
messages: + msg364389
2020-03-16 18:40:05Anthony Sottilesetkeywords: + patch
stage: patch review
pull_requests: + pull_request18379
2020-02-16 19:21:51Anthony Sottilecreate