This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: IDLE: File > Save in 2.7 Shell with non-ascii fails
Type: behavior Stage: resolved
Components: IDLE Versions: Python 2.7
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: terry.reedy, xflr6
Priority: normal Keywords:

Created on 2016-02-10 12:59 by xflr6, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg260008 - (view) Author: Sebastian Bank (xflr6) Date: 2016-02-10 12:59
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'

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).
msg260206 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-02-12 22:12
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\", 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, 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.

2. #21140 is about making the default for mixed code and text files .txt instead of .py.

3. The insertion of /n into the Shell text widget when saving it seems like a bug.  I opened #26353 for this.
Date User Action Args
2022-04-11 14:58:27adminsetgithub: 70515
2016-02-12 22:12:04terry.reedysetstatus: open -> closed

title: File > Save in IDLE shell window not working -> IDLE: File > Save in 2.7 Shell with non-ascii fails
nosy: + terry.reedy

messages: + msg260206
resolution: out of date
stage: resolved
2016-02-10 12:59:49xflr6create