From: Kurt B. Kaiser Date: Sun, 15 Jun 2003 17:49:59 +0000 (+0000) Subject: Forwardport Patch from IDLEfork SF 615312 X-Git-Tag: v2.3c1~433 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7de3772b2834ab18e160626912feb98abecb5104;p=python Forwardport Patch from IDLEfork SF 615312 Convert characters from the locale's encoding on output --- diff --git a/Lib/idlelib/OutputWindow.py b/Lib/idlelib/OutputWindow.py index 9d705d6aee..99e47e486b 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()