Issue35667
Created on 2019-01-05 21:34 by cheryl.sabella, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 14967 | d3r3kk, 2019-07-26 19:03 | ||
| Messages (4) | |||
|---|---|---|---|
| msg333075 - (view) | Author: Cheryl Sabella (cheryl.sabella) * ![]() |
Date: 2019-01-05 21:34 | |
On Windows 10, when I try to activate a venv in powershell where the name contains an apostrophe, I get the following error ("don't" is the name of the venv):
PS N:\projects\cpython\don't\Scripts> .\activate.ps1
At N:\projects\cpython\don't\Scripts\Activate.ps1:42 char:28
+ function global:prompt {
+ ~
Missing closing '}' in statement block or type definition.
At N:\projects\cpython\don't\Scripts\Activate.ps1:37 char:40
+ if (! $env:VIRTUAL_ENV_DISABLE_PROMPT) {
+ ~
Missing closing '}' in statement block or type definition.
At N:\projects\cpython\don't\Scripts\Activate.ps1:43 char:61
+ Write-Host -NoNewline -ForegroundColor Green '(don't) '
+ ~
Unexpected token ')' in expression or statement.
At N:\projects\cpython\don't\Scripts\Activate.ps1:43 char:63
+ Write-Host -NoNewline -ForegroundColor Green '(don't) '
+ ~
The string is missing the terminator: '.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : MissingEndCurlyBrace
This works OK in Command Prompt.
|
|||
| msg333116 - (view) | Author: Karthikeyan Singaravelan (xtreak) * ![]() |
Date: 2019-01-06 18:17 | |
From the error I think the quotes are not properly escaped while doing text replacement in venv activate file template at [0] while it's generated? On linux/Mac double quotes are used and hence the error is not triggered with single quote in virtualenv name. Using double quote in virtualenv name triggers the parse error.
$ python3.7 -m venv py37\"-bpo-35667-venv
$ source py37\"-bpo-35667-venv/bin/activate
py37"-bpo-35667-venv/bin/activate:57: parse error near `then'
Looking into the py37\"-bpo-35667-venv/bin/activate script there is below line where the double quote is unbalanced :
if [ "x(py37"-bpo-35667-venv) " != x ] ; then
PS1="(py37"-bpo-35667-venv) ${PS1:-}"
else
I tried escaping the quotes with backslash at [0] but I get a similar error. I guess it's similar case in Powershell as I can see from Activate.ps1 but I haven't tested it. I am not sure about the difference in semantics between powershell and command prompt with respect to quoting since I don't have access to Windows.
py37\'-bpo-35667-venv/bin/Activate.ps1 file with unbalanced quote
function global:prompt {
Write-Host -NoNewline -ForegroundColor Green '(py37'-bpo-35667-venv) '
_OLD_VIRTUAL_PROMPT
}
[0] https://github.com/python/cpython/blob/a5b76167dedf4d15211a216c3ca7b98e3cec33b8/Lib/venv/__init__.py#L280
|
|||
| msg333125 - (view) | Author: Eryk Sun (eryksun) * ![]() |
Date: 2019-01-07 00:09 | |
> I am not sure about the difference in semantics between powershell and > command prompt with respect to quoting since CMD only uses single quotes in `for /f` loops, in which it's either a command or a literal string (w/ the "usebackq" option). This is not a problem in activate.bat. Double quotes in file names generally shouldn't be a problem in Windows. As far as I know, only the named-pipe file system allows them in pipe-file names (e.g. r'\\?\pipe\"pipename"'), and for regular files they're allowed in stream names (e.g. 'filename:"streamname"'). Otherwise, double quote should be reserved in file names as the DOS_DOT wildcard character. |
|||
| msg351405 - (view) | Author: Vinay Sajip (vinay.sajip) * ![]() |
Date: 2019-09-09 10:22 | |
This has reportedly been fixed by the changes made to fix bpo-37354. I'll close this, but please reopen if you find it's still a problem. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:10 | admin | set | github: 79848 |
| 2019-09-09 10:22:37 | vinay.sajip | set | status: open -> closed resolution: fixed messages: + msg351405 stage: patch review -> resolved |
| 2019-07-26 19:03:13 | d3r3kk | set | keywords:
+ patch stage: patch review pull_requests: + pull_request14736 |
| 2019-01-07 00:09:14 | eryksun | set | nosy:
+ eryksun messages: + msg333125 |
| 2019-01-06 18:17:40 | xtreak | set | nosy:
+ vinay.sajip, xtreak messages: + msg333116 |
| 2019-01-05 21:34:29 | cheryl.sabella | create | |

