diff -r 7e245e785b91 Lib/idlelib/OutputWindow.py --- a/Lib/idlelib/OutputWindow.py Wed Mar 14 22:42:49 2012 +0100 +++ b/Lib/idlelib/OutputWindow.py Wed Mar 14 17:07:04 2012 -0500 @@ -33,11 +33,18 @@ return "no" # Act as output file - def write(self, s, tags=(), mark="insert"): if isinstance(s, (bytes, bytes)): s = s.decode(IOBinding.encoding, "replace") - self.text.insert(mark, s, tags) + try: + self.text.insert(mark, s, tags) + except ValueError: + # let's use ascii while utf8-bmp codec doesn't present + encoding = 'ascii' + s_bytes = s.encode(encoding, 'backslashreplace') + s = s_bytes.decode(encoding, 'strict') + self.text.insert(mark, s, tags) + self.text.see(mark) self.text.update() diff -r 7e245e785b91 Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py Wed Mar 14 22:42:49 2012 +0100 +++ b/Lib/idlelib/PyShell.py Wed Mar 14 17:07:04 2012 -0500 @@ -1221,16 +1221,6 @@ self.set_line_and_column() def write(self, s, tags=()): - if isinstance(s, str) and len(s) and max(s) > '\uffff': - # Tk doesn't support outputting non-BMP characters - # Let's assume what printed string is not very long, - # find first non-BMP character and construct informative - # UnicodeEncodeError exception. - for start, char in enumerate(s): - if char > '\uffff': - break - raise UnicodeEncodeError("UCS-2", char, start, start+1, - 'Non-BMP character not supported in Tk') try: self.text.mark_gravity("iomark", "right") OutputWindow.write(self, s, tags, "iomark") diff -r 7e245e785b91 Lib/idlelib/run.py --- a/Lib/idlelib/run.py Wed Mar 14 22:42:49 2012 +0100 +++ b/Lib/idlelib/run.py Wed Mar 14 17:07:04 2012 -0500 @@ -261,26 +261,6 @@ quitting = True thread.interrupt_main() - -def displayhook(value): - """Override standard display hook to use non-locale encoding""" - if value is None: - return - # Set '_' to None to avoid recursion - builtins._ = None - text = repr(value) - try: - sys.stdout.write(text) - except UnicodeEncodeError: - # let's use ascii while utf8-bmp codec doesn't present - encoding = 'ascii' - bytes = text.encode(encoding, 'backslashreplace') - text = bytes.decode(encoding, 'strict') - sys.stdout.write(text) - sys.stdout.write("\n") - builtins._ = value - - class MyHandler(rpc.RPCHandler): def handle(self): @@ -290,7 +270,6 @@ sys.stdin = self.console = self.get_remote_proxy("stdin") sys.stdout = self.get_remote_proxy("stdout") sys.stderr = self.get_remote_proxy("stderr") - sys.displayhook = displayhook # page help() text to shell. import pydoc # import must be done here to capture i/o binding pydoc.pager = pydoc.plainpager