[Python-bugs-list] [ python-Bugs-805728 ] IDLE can't save UTF-8 files on Windows

SourceForge.net noreply at sourceforge.net
Thu Sep 18 14:26:34 EDT 2003


Bugs item #805728, was opened at 2003-09-13 22:00
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=805728&group_id=5470

Category: IDLE
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Sebastian Wangnick (wangnick)
Assigned to: Kurt B. Kaiser (kbk)
Summary: IDLE can't save UTF-8 files on Windows

Initial Comment:
When trying to save a UTF-8-encoded Python source 

code file containing non-ASCII characters, the new IDLE 

of Python 2.3 (final) fails on Windows:



>>> Exception in Tkinter callback

Traceback (most recent call last):

  File "C:\PYTHON23\lib\lib-tk\Tkinter.py", line 1345, in 

__call__

    return self.func(*args)

  File "C:\PYTHON23\lib\idlelib\IOBinding.py", line 347, in 

save_as

    if self.writefile(filename):

  File "C:\PYTHON23\lib\idlelib\IOBinding.py", line 370, in 

writefile

    chars = chars.replace("\n", self.eol_convention)

UnicodeDecodeError: 'ascii' codec can't decode byte 

0xc3 in position 241: ordinal not in range(128)





The following patch fixes the problem:



*** iobinding.py	Sun Jun 15 17:12:54 2003

--- iobinding.py.new	Thu Sep 11 05:59:54 2003

***************

*** 365,373 ****

  

      def writefile(self, filename):

          self.fixlastline()

!         chars = self.encode(self.text.get("1.0", "end-1c"))

          if self.eol_convention != "\n":

              chars = chars.replace("\n", 

self.eol_convention)

          try:

              f = open(filename, "wb")

              f.write(chars)

--- 365,374 ----

  

      def writefile(self, filename):

          self.fixlastline()

!         chars = self.text.get("1.0", "end-1c")

          if self.eol_convention != "\n":

              chars = chars.replace("\n", 

self.eol_convention)

+         chars = self.encode(chars)

          try:

              f = open(filename, "wb")

              f.write(chars)



----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2003-09-18 20:26

Message:
Logged In: YES 
user_id=21627

Yes, this is fixed with IOBinding.py 1.20.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-09-15 20:01

Message:
Logged In: YES 
user_id=80475

I believe Kurt already fixed this one for Py2.3.1

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=805728&group_id=5470



More information about the Python-bugs-list mailing list