[Python-checkins] python/dist/src/Tools/idle OutputWindow.py,1.5.22.1,1.5.22.2

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Mon, 23 Sep 2002 07:30:26 -0700


Update of /cvsroot/python/python/dist/src/Tools/idle
In directory usw-pr-cvs1:/tmp/cvs-serv7716

Modified Files:
      Tag: release22-maint
	OutputWindow.py 
Log Message:
Backport:

Convert characters from the locale's encoding on output.
Reject characters outside the locale's encoding on input.



Index: OutputWindow.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/idle/OutputWindow.py,v
retrieving revision 1.5.22.1
retrieving revision 1.5.22.2
diff -C2 -d -r1.5.22.1 -r1.5.22.2
*** OutputWindow.py	28 Feb 2002 22:59:02 -0000	1.5.22.1
--- OutputWindow.py	23 Sep 2002 14:30:24 -0000	1.5.22.2
***************
*** 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)