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: don't offer to save text files as .py #72551

Closed
radialbeast mannequin opened this issue Oct 5, 2016 · 9 comments
Closed

IDLE: don't offer to save text files as .py #72551

radialbeast mannequin opened this issue Oct 5, 2016 · 9 comments
Assignees

Comments

@radialbeast
Copy link
Mannequin

radialbeast mannequin commented Oct 5, 2016

BPO 28365
Nosy @terryjreedy, @pfmoore, @tjguk, @stevendaprano, @bitdancer, @zware, @zooba
Superseder
  • bpo-21140: Idle: saving Shell or an OutputWindow should default to .txt
  • Files
  • 2016-10-06 (4).png
  • 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 = <Date 2016-10-06.20:24:56.245>
    created_at = <Date 2016-10-05.15:35:57.595>
    labels = ['expert-IDLE']
    title = "IDLE: don't offer to save text files as .py"
    updated_at = <Date 2016-10-06.20:31:24.763>
    user = 'https://bugs.python.org/radialbeast'

    bugs.python.org fields:

    activity = <Date 2016-10-06.20:31:24.763>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2016-10-06.20:24:56.245>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2016-10-05.15:35:57.595>
    creator = 'radialbeast'
    dependencies = []
    files = ['44988']
    hgrepos = []
    issue_num = 28365
    keywords = []
    message_count = 9.0
    messages = ['278132', '278134', '278135', '278138', '278141', '278142', '278198', '278210', '278211']
    nosy_count = 8.0
    nosy_names = ['terry.reedy', 'paul.moore', 'tim.golden', 'steven.daprano', 'r.david.murray', 'zach.ware', 'steve.dower', 'radialbeast']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '21140'
    type = None
    url = 'https://bugs.python.org/issue28365'
    versions = ['Python 3.5']

    @radialbeast
    Copy link
    Mannequin Author

    radialbeast mannequin commented Oct 5, 2016

    whenever I go to run a program no matter what I do it always says syntax error and highlights the 5 in the 3.5.2 version banner

    @radialbeast radialbeast mannequin added the OS-windows label Oct 5, 2016
    @zware
    Copy link
    Member

    zware commented Oct 5, 2016

    Hi A.J.,

    What you're describing isn't really possible, so you're going to need to provide some more detail. Please copy and paste your Command Prompt session into a message here to show us what's going on.

    @tjguk
    Copy link
    Member

    tjguk commented Oct 5, 2016

    This sometimes happens when someone copies from a book or a tutorial and
    includes as though code the banner header which is only meant to
    illustrate the context.

    @stevendaprano
    Copy link
    Member

    See bpo-28366

    @pfmoore
    Copy link
    Member

    pfmoore commented Oct 5, 2016

    I can recreate this (based on the screenshots from bpo-28366).

    To reproduce, open IDLE. You get the console banner and prompt. Save that file using File-Save. The close IDLE. Reopen it, do File-Open to open your saved console session, then use the "Run" menu to run it. (You need to close IDLE, so it "forgets" the .py file came from a console session.)

    That's incorrect usage, of course (not "of course" to the OP - that's the real point here) as the text of a console session isn't a valid Python file, and doesn't syntax check. The error is saying precisely that - what is in the file isn't valid Python.

    So in one sense, this is simply user error. But I wonder, is there something about how IDLE presents things that could be improved? Either in the documentation or in the UI? I'm not exactly sure what the point of "file-save" in a console window is, and certainly it would be better to save the transcript as text so it couldn't be inadvertently be read back in as a Python module.

    I'm not an IDLE user, though, so I don't really have the background to know the best solution.

    @bitdancer
    Copy link
    Member

    I'm retitling the issue. The new title doesn't necessary represent the "bug" that needs to be fixed, but it does seem to represent the *apparent* error.

    @bitdancer bitdancer changed the title 3.5.2 syntax issue idle forgets that saved console session is not a python file after restart Oct 5, 2016
    @radialbeast
    Copy link
    Mannequin Author

    radialbeast mannequin commented Oct 6, 2016

    There is no other way to explain it without fail every time no matter what code I write there is always syntax error highlighted on the five in the version banner.

    @terryjreedy
    Copy link
    Member

    I am closing this as a duplicate of existing bpo-21140, to make .txt instead of .py the extension for files known not to be code files. I There is an existing simple patch. I will modify it to not even offer .py as a secondary choice.

    The reason Paul had to close IDLE to open the file in an(other) editor window is that Python allows only one editor window per file, and Shell is a subclass of OutputWindow, which is a subclass of EditorWindow. (The latter inheritance is backwards; OutputWindow should be the base TextEditor and 'CodeEditor' a subclass thereof.) When Shell is saved, the file name appears on the recent files list, and attempts to open it make the exiting editor the active window.

    Angie, as Paul explained, your screenshot shows a text file, mislabeled as a .py python file, in the editor. When you run non-code text as code, you get a SyntaxError. The text file appears to be a saved interactive shell session. "Python 3" by itself is a SyntaxError and will continue to be an error no matter what follows.

    It is possible that your Python installation, or the IDLE part of it, is badly broken, and needs to be repaired or re-installed. But I think it much much more likely that you have made a mistake. If you want to discuss this further, please post to python-list (or its news.gmane.org mirror). Include a link to this issue, give a detailed description of what you did (keystrokes and mouse clicks), and ask any questions.

    @terryjreedy terryjreedy changed the title idle forgets that saved console session is not a python file after restart IDLE: don't offer to save text files as .py Oct 6, 2016
    @terryjreedy
    Copy link
    Member

    PS. A.J., you will likely be a happier user if you make a subdirectory under c:/Users/angie and put your files there instead of in the installation directory under the hidden AppDate

    @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
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants