diff options
author | Kurt B. Kaiser <kbk@shore.net> | 2003-06-15 17:49:59 (GMT) |
---|---|---|
committer | Kurt B. Kaiser <kbk@shore.net> | 2003-06-15 17:49:59 (GMT) |
commit | 7de3772b2834ab18e160626912feb98abecb5104 (patch) | |
tree | 7de7c42cf49d6a5efc148123de09e9082c623210 /Lib/idlelib/OutputWindow.py | |
parent | 9e8b828f07d0a55676e987b4ca70c247853f5695 (diff) | |
download | cpython-7de3772b2834ab18e160626912feb98abecb5104.zip cpython-7de3772b2834ab18e160626912feb98abecb5104.tar.gz cpython-7de3772b2834ab18e160626912feb98abecb5104.tar.bz2 |
Forwardport Patch from IDLEfork SF 615312
Convert characters from the locale's encoding on output
Diffstat (limited to 'Lib/idlelib/OutputWindow.py')
-rw-r--r-- | Lib/idlelib/OutputWindow.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/idlelib/OutputWindow.py b/Lib/idlelib/OutputWindow.py index 9d705d6..99e47e4 100644 --- a/Lib/idlelib/OutputWindow.py +++ b/Lib/idlelib/OutputWindow.py @@ -2,6 +2,7 @@ from Tkinter import * from EditorWindow import EditorWindow import re import tkMessageBox +import IOBinding class OutputWindow(EditorWindow): @@ -34,6 +35,14 @@ class OutputWindow(EditorWindow): # Act as output file 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) self.text.update() |