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: File > Save in 2.7 Shell with non-ascii fails #70515

Closed
xflr6 mannequin opened this issue Feb 10, 2016 · 2 comments
Closed

IDLE: File > Save in 2.7 Shell with non-ascii fails #70515

xflr6 mannequin opened this issue Feb 10, 2016 · 2 comments
Labels
topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@xflr6
Copy link
Mannequin

xflr6 mannequin commented Feb 10, 2016

BPO 26327
Nosy @terryjreedy, @xflr6

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 = None
closed_at = <Date 2016-02-12.22:12:04.002>
created_at = <Date 2016-02-10.12:59:49.949>
labels = ['expert-IDLE', 'type-bug']
title = 'IDLE: File > Save in 2.7 Shell with non-ascii fails'
updated_at = <Date 2016-02-12.22:12:04.001>
user = 'https://github.com/xflr6'

bugs.python.org fields:

activity = <Date 2016-02-12.22:12:04.001>
actor = 'terry.reedy'
assignee = 'none'
closed = True
closed_date = <Date 2016-02-12.22:12:04.002>
closer = 'terry.reedy'
components = ['IDLE']
creation = <Date 2016-02-10.12:59:49.949>
creator = 'xflr6'
dependencies = []
files = []
hgrepos = []
issue_num = 26327
keywords = []
message_count = 2.0
messages = ['260008', '260206']
nosy_count = 2.0
nosy_names = ['terry.reedy', 'xflr6']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue26327'
versions = ['Python 2.7']

@xflr6
Copy link
Mannequin Author

xflr6 mannequin commented Feb 10, 2016

Under Python 2.7.11 (Win 7), saving of the IDLE shell output produces no file if the output contains non-ASCII characters, e.g. after doing (before this, it does work):

>>> print u'sp\xe4m'
späm
>>> 

When saving (generally), the cursor also moves to the next line.

Maybe the default file type for the shell save dialog(s) can be changed from 'Python Files (.py, *.pyw)' to the other entry 'Text files (.txt)' as the resulting file will normally not be a valid Python file (e.g. due to '>>>' prompts).

@xflr6 xflr6 mannequin added topic-IDLE type-bug An unexpected behavior, bug, or error labels Feb 10, 2016
@terryjreedy
Copy link
Member

You raised three issues.

  1. If you run IDLE from a console (Command Prompt or Powershell) you will see the no-save cause.

C:\Users\Terry>py -m idlelib.idle
Exception in Tkinter callback
...
File "C:\Programs\Python27\lib\idlelib\IOBinding.py", line 433, in encode
config_encoding = idleConf.GetOption("main","EditorWindow",
NameError: global name 'idleConf' is not defined

This a bug I introduced into 2.7.11 and have already fixed in the repository (hence 'out of date'). The line above is only executed when there are non-ascii chars, which is why saving worked before you added the non-ascii char.

To get the fix now, in your copy of IOBinding.py, move the line

    from idlelib.configHandler import idleConf

in "def _io_binding" near the bottom of the file to the end of the imports near the top. Remove the indent before saving.

  1. bpo-21140 is about making the default for mixed code and text files .txt instead of .py.

  2. The insertion of /n into the Shell text widget when saving it seems like a bug. I opened bpo-26353 for this.

@terryjreedy terryjreedy changed the title File > Save in IDLE shell window not working IDLE: File > Save in 2.7 Shell with non-ascii fails Feb 12, 2016
@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
topic-IDLE type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant