classification
Title: Enhance 2.7 IDLE to exec IDLESTARTUP/PYTHONSTARTUP on restart
Type: behavior Stage:
Components: IDLE Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: kbk Nosy List: MLModel, cben, gpolo, kbk
Priority: normal Keywords: patch

Created on 2009-02-12 22:34 by MLModel, last changed 2010-03-16 20:15 by cben.

Files
File name Uploaded Description Edit
PyShell-2.7.diff MLModel, 2009-02-12 22:34 mods to enable IDLE's loading startup file on restart review
PyShell-3.1.diff MLModel, 2009-03-09 14:45 mods to enable IDLE's loading startup file on restart in Python 3 review
startup-2.7.diff cben, 2010-03-16 20:15 and now actually run them after restart review
Messages (4)
msg81831 - (view) Author: Mitchell Model (MLModel) Date: 2009-02-12 22:34
The main thing the patch does is:
	modify the subprocess restart procedure so that it reloads 
whatever file, if any, was loaded when IDLE first started and looked for 
IDLESTARTUP then PYTHONSTARTUP environment variables.

In addition:
	a -q option is added for starting IDLE on the command line to 
mean "quiet", as with Emacs, e.g., to suppress loading of IDLESTARTUP or 
PYTHONSTARTUP
	The former effect of -s would now be the default, which is 
desirable so double-clicking an IDLE icon to start it will cause the 
startup file to run.
	-s is changed to take an argument that is an alternate startup 
file to use

I am a bit concerned about changing -s to have a different meaning. 
Perhaps it's better to leave -s as an option that is simplhy superfluous 
and use a different letter for the alternate startup.
msg83386 - (view) Author: Mitchell Model (MLModel) Date: 2009-03-09 14:45
Adding patch for 3.1 from issue 5234 to this as per Martin's request.
msg83399 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-03-09 19:22
Assigning to kbk since 5234 was assigned to him.
msg101183 - (view) Author: Cherniavsky Beni (cben) Date: 2010-03-16 20:15
Oops!  Mitchell's patch didn't actually run the startup code after restart.  Fixed patch attached (updated against 2.7 trunk).  Also added some doc updates.  Too lazy to produce a 3.2 version now.

[Apology to Mitchell: I removed most of your comments explaining the change and attributing it to you.  Nothing personal, just that's we have version control to store that info.]

Open questions / doubts:

* I described it in Lib/idlelib/NEWS.txt - correct?

* There is much duplication between the Doc/library/idle.rst, the command-line help string in PyShell.py and the option parsing code.  Maybe it should be rewritten with optparse?  [Doesn't block this patch.]

* There is much duplication between begin()/start_subprocess() and restart_subprocess().  These pieces of the code have a history of being fragile, and having subtle differences between them is a bad idea :-(  I didn't dare refactor them as I can't test such changes widely enough, so the startup call is duplicated.

* When a script is being run, should the startup file run before or after it (or at all)?  Currently it runs before the script, which is good because it can e.g. set the excepthook, and bad because it's different from running in a clean Python.   (Python doesn't run PYTHONSTARTUP at all when running a script, even in -i mode.)
Opinions?  Anyway, it's hard to implement otherwise with currect runcode().

[Unrelated to the patch but bothering me: it seems that runcode() sometimes restart the shell and sometimes not, and is used in both capacities?!  This is very confusing.  Or am I just reading it wrong?]
History
Date User Action Args
2010-03-16 20:15:09cbensetfiles: + startup-2.7.diff
nosy: + cben
messages: + msg101183

2009-03-09 19:22:22gpolosetassignee: kbk

messages: + msg83399
nosy: + gpolo, kbk
2009-03-09 19:21:38gpololinkissue5234 superseder
2009-03-09 14:45:28MLModelsetfiles: + PyShell-3.1.diff

messages: + msg83386
versions: + Python 2.6, Python 3.0, Python 3.1
2009-02-12 22:34:41MLModelcreate