Skip to content
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

Open
terryjreedy opened this issue Apr 3, 2014 · 9 comments
Open

Idle: saving Shell or an OutputWindow should default to .txt #65339

terryjreedy opened this issue Apr 3, 2014 · 9 comments
Assignees
Labels
3.10 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

BPO 21140
Nosy @rhettinger, @terryjreedy
Files
  • issue21140-27.patch
  • issue21140-34.patch
  • 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:

    assignee = 'https://github.com/terryjreedy'
    closed_at = None
    created_at = <Date 2014-04-03.02:47:39.804>
    labels = ['expert-IDLE', 'type-bug', '3.10']
    title = 'Idle: saving Shell or an OutputWindow should default to .txt'
    updated_at = <Date 2021-09-27.06:07:06.718>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2021-09-27.06:07:06.718>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = False
    closed_date = None
    closer = None
    components = ['IDLE']
    creation = <Date 2014-04-03.02:47:39.804>
    creator = 'terry.reedy'
    dependencies = []
    files = ['34713', '34714']
    hgrepos = []
    issue_num = 21140
    keywords = ['patch']
    message_count = 9.0
    messages = ['215419', '215454', '215485', '215500', '260207', '278169', '278209', '370850', '402692']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'terry.reedy', 'Saimadhav.Heblikar']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue21140'
    versions = ['Python 3.10']

    @terryjreedy
    Copy link
    Member Author

    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.

    @terryjreedy terryjreedy added topic-IDLE type-bug An unexpected behavior, bug, or error labels Apr 3, 2014
    @SaimadhavHeblikar
    Copy link
    Mannequin

    SaimadhavHeblikar mannequin commented Apr 3, 2014

    Attaching a patch.
    The file type on OutputWIndow defaults to .txt. Can be very easily made to default to none aswell.

    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)

    @rhettinger
    Copy link
    Contributor

    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).

    @terryjreedy
    Copy link
    Member Author

    Raymond, I open bpo-21152 with your idea. bpo-11838 and bpo-19042 are somewhat related but timed autosave is not a part of either.

    @terryjreedy
    Copy link
    Member Author

    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.

    @terryjreedy terryjreedy changed the title Idle: saving an OutputWindow should default to .txt Idle: saving Shell or an OutputWindow should default to .txt Feb 12, 2016
    @terryjreedy
    Copy link
    Member Author

    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

    @terryjreedy terryjreedy added the 3.7 (EOL) end of life label Oct 6, 2016
    @terryjreedy terryjreedy self-assigned this Oct 6, 2016
    @terryjreedy
    Copy link
    Member Author

    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.

    @terryjreedy
    Copy link
    Member Author

    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.

    @terryjreedy terryjreedy added 3.10 only security fixes and removed 3.7 (EOL) end of life labels Jun 6, 2020
    @terryjreedy
    Copy link
    Member Author

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    Status: No status
    Development

    No branches or pull requests

    2 participants