[issue5680] Simulate command-line arguments for program run in IDLE

Terry J. Reedy report at bugs.python.org
Sat Jun 1 20:15:09 EDT 2019


Terry J. Reedy <tjreedy at udel.edu> added the comment:

3 recent 'doit' requests (2 on PR 1589) raise my priority for this issue.

When a user runs a file from an editor, IDLE simulates, as well as it can, the user entering 'python -i path' in a system command line shell.   Both on a command line and in IDLE, the program starts with sys.argv = ['path'] (at least on my Windows system).  This can be shown by running a file with 'import sys; print(sys.path)' both ways.

The request for this issue is to simulate 'python -i path a1, a2, ...'.
The program should start with sys.argv = ['path', 'a1', 'a2', '...'], with the argument strings being the same as they would be if entered at a command line on the *same system*.

I have looked at least a bit at all 4 patches and have decided to start fresh, using just a few existing lines.  The latest of the 4 was submitted 2 years ago, while I was learning to use git.

By the following September, using config-extensions was obsolete.  *If* we want to save a command string across sessions, a line could be added to config-main.  But I am dubious about this.  I expect that users will want to vary argument values for 1 program and need different sets of arguments for different programs.


I want to use a subclass of idlelib.query.Query for the query box.  No need to reinvent it.

I believe that argument strings should be parsed into an argument list using shlex.split.  No need to reinvent that either.  But I am not an expert in this area and the doc it rather vague.  I suspect that 'posix=False' should be used on Windows.  Does anyone know?  Gabriel's patch is the only one using shlex.split, but always with the default 'posix=True'.

Saimadhav tested his patch on Debian.  The others did not say.  A verified-by-human htest should be added to runscript.py, and manual test running 'import sys; print(sys.argv)' from an editor done on the 3 major OSes.

----------
stage: patch review -> needs patch
title: Command-line arguments when running in IDLE -> Simulate command-line arguments for program run in IDLE
versions: +Python 3.8 -Python 3.6

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


More information about the Python-bugs-list mailing list