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.

classification
Title: IDLE doesn't save 8bit files
Type: Stage:
Components: IDLE Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: loewis Nosy List: afayolle, loewis, nnorwitz, nobody
Priority: normal Keywords:

Created on 2002-04-18 11:28 by afayolle, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (7)
msg10404 - (view) Author: Alexandre Fayolle (afayolle) Date: 2002-04-18 11:28
This bug seems to be related to #527022. 

Short version is: IDLE won't save files containing 8bit
characters (for instance in comments or in litteral
strings). No error dialog is displayed, only a
traceback on stderr or in the interactive window if
it's available:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.1/lib-tk/Tkinter.py", line
1285, in __call__
    return apply(self.func, args)
  File "/usr/lib/idle-python2.1/IOBinding.py", line
126, in save
    self.save_as(event)
  File "/usr/lib/idle-python2.1/IOBinding.py", line
136, in save_as
    if self.writefile(filename):
  File "/usr/lib/idle-python2.1/IOBinding.py", line
154, in writefile
    f.write(chars)
UnicodeError: ASCII encoding error: ordinal not in
range(128)

Possible solution:

 * at least warn the user that the file could not be
saved with an error dialog
 * try using the locale to guess the encoding and do
appropriate conversions
 * ask the user wich encoding should be used to save
the file
msg10405 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-04-19 08:23
Logged In: YES 
user_id=21627

In this form, this is not a bug. IDLE cannot know what
encoding you want to use the file.

Under PEP 263, you will need to declare the encoding inside
the file; then IDLE will use the declared encoding. See

http://sourceforge.net/tracker/index.php?func=detail&aid=508973&group_id=9579&atid=309579
msg10406 - (view) Author: Alexandre Fayolle (afayolle) Date: 2002-04-19 09:30
Logged In: YES 
user_id=116727

I like the solution proposed in the reference.

However, having just a traceback printed on the console
looks like a bug to me. I expect IDLE to complain loudly in
case it cannot save my file. If it could give me a hint as
to what to add to the file to be able to save it, that'd be
even better. 

Cheers 

Alexandre 
msg10407 - (view) Author: Nobody/Anonymous (nobody) Date: 2002-08-13 22:21
Logged In: NO 

Also, the file gets destroyed - truncated to 0 bytes, after 
such unsucessful save.
msg10408 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-08-14 06:56
Logged In: YES 
user_id=21627

Please try CVS IDLE. It corrects these problems.
msg10409 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-09-13 14:05
Logged In: YES 
user_id=33168

I tested this and it seemed to work (not that I know what
I'm doing, but there were 8 bit characters and they were
saved correctly).  Should this bug be closed?
msg10410 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-09-13 15:07
Logged In: YES 
user_id=21627

Sure!
History
Date User Action Args
2022-04-10 16:05:14adminsetgithub: 36462
2002-04-18 11:28:27afayollecreate