From 7827e1707c3727f51b553881bb389adf42b016e6 Mon Sep 17 00:00:00 2001 From: "Kurt B. Kaiser" Date: Tue, 17 Sep 2002 03:40:47 +0000 Subject: 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. --- Lib/idlelib/OutputWindow.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Lib/idlelib/OutputWindow.py b/Lib/idlelib/OutputWindow.py index 7522720..181238f 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() -- cgit v0.12