[Idle-dev] CVS: idle OutputWindow.py,1.5,1.6
Kurt B. Kaiser
kbk@users.sourceforge.net
Mon, 16 Sep 2002 20:40:49 -0700
Update of /cvsroot/idlefork/idle
In directory usw-pr-cvs1:/tmp/cvs-serv13642
Modified Files:
OutputWindow.py
Log Message:
Merge Py Idle changes:
Rev 1.7 loewis
Convert characters from the locale's encoding on output.
Reject characters outside the locale's encoding on input.
Index: OutputWindow.py
===================================================================
RCS file: /cvsroot/idlefork/idle/OutputWindow.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** OutputWindow.py 2 Sep 2002 21:29:40 -0000 1.5
--- OutputWindow.py 17 Sep 2002 03:40:47 -0000 1.6
***************
*** 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)