diff options
author | Kurt B. Kaiser <kbk@shore.net> | 2002-09-17 03:40:47 (GMT) |
---|---|---|
committer | Kurt B. Kaiser <kbk@shore.net> | 2002-09-17 03:40:47 (GMT) |
commit | 7827e1707c3727f51b553881bb389adf42b016e6 (patch) | |
tree | fffa70fd0a0feaaee08a79dba37b237e825d8703 /Lib | |
parent | e5de77800e905a4bc90f7568eb106aa9e276b590 (diff) | |
download | cpython-7827e1707c3727f51b553881bb389adf42b016e6.zip cpython-7827e1707c3727f51b553881bb389adf42b016e6.tar.gz cpython-7827e1707c3727f51b553881bb389adf42b016e6.tar.bz2 |
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.
Diffstat (limited to 'Lib')
-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 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() |