Staging
v0.5.1
https://github.com/python/cpython
Revision 720ba1f26e452dc64538098e78b047614a7f7e99 authored by Anthony Baxter on 18 April 2002, 05:09:06 UTC, committed by Anthony Baxter on 18 April 2002, 05:09:06 UTC
Provisional fix for writefile() [SF bug # 541730].

The problem was that an exception can occur in the text.get() call or
in the write() call, when the text buffer contains non-ASCII
characters.  This causes the previous contents of the file to be lost.

The provisional fix is to call str(self.text.get(...)) *before*
opening the file, so that if the exception occurs, we never open the
file.

Two orthogonal better solutions have to wait for policy decisions:

1. We could try to encode the data as Latin-1 or as UTF-8; but that
   would require IDLE to grow a notion of file encoding which requires
   more thought.

2. We could make backups before overwriting a file.  This requires
   more thought because it needs to be fast and cross-platform and
   configurable.


Original patches were:
python/dist/src/Tools/idle/IOBinding.py:1.6
1 parent 56f9350
History
Tip revision: 720ba1f26e452dc64538098e78b047614a7f7e99 authored by Anthony Baxter on 18 April 2002, 05:09:06 UTC
backport gvanrossum's patch:
Tip revision: 720ba1f
File Mode Size
Demo
Doc
Grammar
Include
Lib
Mac
Misc
Modules
Objects
PC
PCbuild
Parser
Python
RISCOS
Tools
.cvsignore -rw-r--r-- 79 bytes
.hgtags -rw-r--r-- 2.3 KB
LICENSE -rw-r--r-- 11.5 KB
Makefile.pre.in -rw-r--r-- 21.8 KB
README -rw-r--r-- 38.8 KB
acconfig.h -rw-r--r-- 6.3 KB
config.h.in -rw-r--r-- 17.1 KB
configure -rwxr-xr-x 181.7 KB
configure.in -rw-r--r-- 38.2 KB
install-sh -rwxr-xr-x 5.5 KB
setup.py -rw-r--r-- 25.2 KB

README

back to top