[Python-checkins] python/dist/src/Lib/idlelib OutputWindow.py,1.8,1.9

kbk@users.sourceforge.net kbk@users.sourceforge.net
2003年6月15日 10:50:01 -0700


Update of /cvsroot/python/python/dist/src/Lib/idlelib
In directory sc8-pr-cvs1:/tmp/cvs-serv3103
Modified Files:
	OutputWindow.py 
Log Message:
Forwardport Patch from IDLEfork SF 615312
Convert characters from the locale's encoding on output
Index: OutputWindow.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/idlelib/OutputWindow.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** OutputWindow.py	31 Dec 2002 15:59:14 -0000	1.8
--- OutputWindow.py	15 Jun 2003 17:49:59 -0000	1.9
***************
*** 3,6 ****
--- 3,7 ----
 import re
 import tkMessageBox
+ import IOBinding
 
 class OutputWindow(EditorWindow):
***************
*** 35,38 ****
--- 36,47 ----
 
 def write(self, s, tags=(), mark="insert"):
+ # Tk assumes that byte strings are Latin-1;
+ # we assume that they are in the locale's encoding
+ if isinstance(s, str):
+ try:
+ s = unicode(s, IOBinding.encoding)
+ except UnicodeError:
+ # some other encoding; let Tcl deal with it
+ pass
 self.text.insert(mark, s, tags)
 self.text.see(mark)

AltStyle によって変換されたページ (->オリジナル) /