New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idle: saving Shell or an OutputWindow should default to .txt #65339
Comments
If possible, when saving an instance of an OutputWindow, the file type should default to .txt (or possibly even nothing) instead of .py. At present, OutputWindows are only used for Find in Files (grep) output, which is very much not Python code. The same should be true of any other OutputWindow uses, which I except there will be, making OutputWindow saves more common. A patch should be tested and verified on Mac, Linux, and Windows. |
Attaching a patch. Tested on linux for 2.7 and 3.4.(Debian Wheezy, Gnome 3) On 2.7, made changes so that ispythonsource(in EditorWindow) behaves similar to 3.4(in EditorWindow) On both 2.7 and 3.4, made change to ispythonsource(in OutputWindow), to make it return False instead of 0(to mirror behavior in EditorWindow) |
FWIW, students commonly save shell sessions as a record of everything they tried in call. It would nice if there were a way to trigger a periodic autosave (perhaps every five minutes or so). |
In bpo-11830 I suggested that Shell should be added to this issue. bpo-26327 does the same, as the prompt and output are not code. At least in 3.x, these mixed code and text files should be encoded utf-8 (which is the same as ascii for all ascii files), as code files are (at least by default). The encoding search and determination in IDBinding.py is a bit baroque. The local encoding should not ever be used for 3.x code. If we do something with bpo-11838 (save runnable code from Shell), the default should then revert to .py. I don't want a patch here to make this excessively difficult. |
I am closing bpo-28365 in favor of this. As noted there, Shell is a subclass of OutputWindow is a subclass of EditorWindow, so Shell should inherit new behavior from OutputWindow instead of both from EW. Change to the patch: I think .py should not even be a selectable option as Shell cannot be edited down to code, and it would make no sense to do so. And anyone who did want to save as .py could select 'all types' and type '.py' explicitly. I was thinking that filetype should be set in OutputWindow, but that does not include text files in an editor window (with editwin.ispythonsource(self.filename) False). Another reason is that I want to change the editor class structure. Currently. the editor window used for all files is the confusingly named PyShellEditorWindow in pyshell.py, which adds breakpoints to EditorWindow. In long run, EditorWindow should be used for non-python editing. The current PyShellEditorWindow should become PythonEditor and have all the attributes and methods specific to python code. Then EditorWindow.filetypes would have .txt and *.* and .py would be added in PythonEditor. It would also, then, not be necessary to disable code stuff in OutputWindow (like the Run menu). (In fact, it might turn out that EditorWindow and OutputWindow would be the same, a base TextEditor |
A more drastic change would be to refuse to save OutputWindow and Shell as .py(w,o) files. bpo-28365 is about a beginner who apparently save a short Shell session as .py, quit IDLE, loaded the saved session in an editor, and tried to run it. |
There was a recent stackoverflow question in which newbie pulled shell log into editor and ran as is. Got SyntaxError as 'Python 3' start of startup message. |
From bpo-45297, closed as duplicate. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: