mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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.
This commit is contained in:
parent
e5de77800e
commit
7827e1707c
1 changed files with 9 additions and 0 deletions
|
@ -2,6 +2,7 @@ from Tkinter import *
|
||||||
from EditorWindow import EditorWindow
|
from EditorWindow import EditorWindow
|
||||||
import re
|
import re
|
||||||
import tkMessageBox
|
import tkMessageBox
|
||||||
|
import IOBinding
|
||||||
|
|
||||||
class OutputWindow(EditorWindow):
|
class OutputWindow(EditorWindow):
|
||||||
|
|
||||||
|
@ -34,6 +35,14 @@ class OutputWindow(EditorWindow):
|
||||||
# Act as output file
|
# Act as output file
|
||||||
|
|
||||||
def write(self, s, tags=(), mark="insert"):
|
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.insert(mark, s, tags)
|
||||||
self.text.see(mark)
|
self.text.see(mark)
|
||||||
self.text.update()
|
self.text.update()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue