[New-bugs-announce] [issue37661] venv activation scripts erroneously check if __VENV_PROMPT__ is defined

Brett Cannon report at bugs.python.org
Tue Jul 23 15:17:07 EDT 2019


New submission from Brett Cannon <brett at python.org>:

If you look at https://github.com/python/cpython/blob/master/Lib/venv/__init__.py#L112-L113 you will see that the prompt context for a virtual environment is always set. Then if you look at the string substitutions for the activation scripts you will also see that the string substitution for __VENV_PROMPT__ is thus always done.

This is an issue as it means that for the fish and bash activation scripts they have erroneous checks for custom prompts. I.e. https://github.com/python/cpython/blob/master/Lib/venv/scripts/posix/activate.fish#L55 for fish and https://github.com/python/cpython/blob/master/Lib/venv/scripts/common/activate#L57 for bash will never fail, halting any other further checks unless one creates a custom EnvBuilder class which will make sure the prompt context stays empty all the way to string substitution. This impacts the colouring of the prompt in fish as that's only done if there is no default prompt (which is never true).

----------
components: Library (Lib)
messages: 348346
nosy: brett.cannon, vinay.sajip
priority: normal
severity: normal
status: open
title: venv activation scripts erroneously check if __VENV_PROMPT__ is defined
type: behavior

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37661>
_______________________________________


More information about the New-bugs-announce mailing list