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

Improve the IDLE shell save command #89460

Open
stevendaprano opened this issue Sep 27, 2021 · 2 comments
Open

Improve the IDLE shell save command #89460

stevendaprano opened this issue Sep 27, 2021 · 2 comments
Assignees
Labels
3.11 only security fixes topic-IDLE type-feature A feature request or enhancement

Comments

@stevendaprano
Copy link
Member

BPO 45297
Nosy @terryjreedy, @stevendaprano

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 2021-09-27.00:28:07.219>
labels = ['expert-IDLE', 'type-feature', '3.11']
title = 'Improve the IDLE shell save command'
updated_at = <Date 2022-03-20.22:25:42.712>
user = 'https://github.com/stevendaprano'

bugs.python.org fields:

activity = <Date 2022-03-20.22:25:42.712>
actor = 'steven.daprano'
assignee = 'terry.reedy'
closed = False
closed_date = None
closer = None
components = ['IDLE']
creation = <Date 2021-09-27.00:28:07.219>
creator = 'steven.daprano'
dependencies = []
files = []
hgrepos = []
issue_num = 45297
keywords = []
message_count = 2.0
messages = ['402686', '415638']
nosy_count = 2.0
nosy_names = ['terry.reedy', 'steven.daprano']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue45297'
versions = ['Python 3.11']

@stevendaprano
Copy link
Member Author

See this question on Discuss:

https://discuss.python.org/t/what-is-this-syntax-i-dont-know-how-to-fix-it/10844

It seems that IDLE allows you to save the shell output, complete with welcome message and prompts, as a .py file, and then reopen it and attempt to run it, which obviously fails. When it does fail, it is confusing.

Suggested enhancements:

  • When saving the complete shell session, save it to a text file, not .py. That would be useful for anyone wanting a full record of the interpreter session.

  • When saving the shell session as a .py file, strip out the welcome message, the prompts, and any output, leaving only what will hopefully be runnable code.

I don't know what sort of UI this should have. Two different menu commands? A checkbox in the Save dialog?

My thoughts are that the heuristic to reconstruct runnable code from the interpreter session may not be foolproof, but better than nothing. Something like the doctest rules might work reasonably well.

  • strip the welcome message;
- any line (or block) starting with the prompt >>> that is followed by a traceback should be thrown out;

- any other text not starting with the prompt >>> is interpreter output and should be thrown out;
  • you should be left with just blocks starting with the prompt, so remove the prompt, adjust the indents, and hopefully you're left with valid runnable code.

@stevendaprano stevendaprano added the 3.11 only security fixes label Sep 27, 2021
@stevendaprano stevendaprano added topic-IDLE type-feature A feature request or enhancement 3.11 only security fixes labels Sep 27, 2021
@stevendaprano stevendaprano added topic-IDLE type-feature A feature request or enhancement labels Sep 27, 2021
@stevendaprano
Copy link
Member Author

Here is another example of a newbie caught by this:

https://discuss.python.org/t/syntax-error-in-python-3-10-when-running-on-terminal/14462

@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.11 only security fixes topic-IDLE type-feature A feature request or enhancement
Projects
Status: No status
Development

No branches or pull requests

2 participants