You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Command line arguments passed into a python script are processed by pyenv shims causing unexpected results if they contain text that look like a batch file variable, i.e. contain a % character, including
Argument position parameters (e.g. %0, %*), parameter extensions (e.g. %~p0), and environment variables (e.g. %PATH%, %DATE%) will be expanded before they are passed into the python script.
Single % characters are removed from arguments passed into the python script, e.g. %foo will pass in foo.
Multiple % surrounding text cause the entire text to be removed, e.g. a%foo%b will pass in ab, while %foo% will be removed entirely and not seen as an argument at all.
Bad expansions may cause pyenv to error, e.g. %~foo.
Issue can be worked around by escaping the % character but requires multiple escapes, e.g. %%%%0 will provide the python string %0.
To Reproduce
Given a python script that takes command line arguments, e.g.
run the script with arguments that match Windows batch file variables
python args.py a0-%0 a1-%1 a2-%2
Expected behavior
Preferably arguments should be passed to python as if running python directly, without batch expansions. If that is not possible, perhaps a more intuitive way to escape % for a literal character.
Screenshots
Running python through pyenv shims expands parameters
PS C:\Users\me> python args.py %~foo
The following usage of the path operator in batch-parameter
substitution is invalid: %~foo
For valid formats type CALL /? or FOR/?
Desktop (please complete the following information):
OS: Windows 10
Tools used: Powershell 7
Version: 2.64.3
Additional context
Discovered while working on a script to process URLs containing a space in the path, which would be translated to %20, e.g. https://example.com/a%20file.txt.
The text was updated successfully, but these errors were encountered:
Describe the bug
Command line arguments passed into a python script are processed by pyenv shims causing unexpected results if they contain text that look like a batch file variable, i.e. contain a
%
character, including%0
,%*
), parameter extensions (e.g.%~p0
), and environment variables (e.g.%PATH%
,%DATE%
) will be expanded before they are passed into the python script.%
characters are removed from arguments passed into the python script, e.g.%foo
will pass infoo
.%
surrounding text cause the entire text to be removed, e.g.a%foo%b
will pass inab
, while%foo%
will be removed entirely and not seen as an argument at all.%~foo
.Issue can be worked around by escaping the
%
character but requires multiple escapes, e.g.%%%%0
will provide the python string%0
.To Reproduce
Given a python script that takes command line arguments, e.g.
run the script with arguments that match Windows batch file variables
Expected behavior
Preferably arguments should be passed to python as if running python directly, without batch expansions. If that is not possible, perhaps a more intuitive way to escape
%
for a literal character.Screenshots
Running python through pyenv shims expands parameters
Running python directly passes argument strings correctly.
Passing bad parameters throws errors.
Desktop (please complete the following information):
Additional context
Discovered while working on a script to process URLs containing a space in the path, which would be translated to
%20
, e.g.https://example.com/a%20file.txt
.The text was updated successfully, but these errors were encountered: