From: Serhiy Storchaka Date: Sun, 17 May 2015 10:53:54 +0000 (+0300) Subject: Issue #15809: IDLE shell now uses locale encoding instead of Latin1 for X-Git-Tag: v2.7.11rc1~302^2~15 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4b2c468e7464dc29700b50afcfc0bf101bea7fb8;p=thirdparty%2FPython%2Fcpython.git Issue #15809: IDLE shell now uses locale encoding instead of Latin1 for decoding unicode literals. --- diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py index 17ca0ef3f80a..8ee0c0e7466e 100755 --- a/Lib/idlelib/PyShell.py +++ b/Lib/idlelib/PyShell.py @@ -34,6 +34,7 @@ from idlelib import rpc from idlelib import Debugger from idlelib import RemoteDebugger from idlelib import macosxSupport +from idlelib import IOBinding IDENTCHARS = string.ascii_letters + string.digits + "_" HOST = '127.0.0.1' # python execution server on localhost loopback @@ -668,10 +669,11 @@ class ModifiedInterpreter(InteractiveInterpreter): self.more = 0 self.save_warnings_filters = warnings.filters[:] warnings.filterwarnings(action="error", category=SyntaxWarning) - if isinstance(source, unicode): - from idlelib import IOBinding + if isinstance(source, unicode) and IOBinding.encoding != 'utf-8': try: - source = source.encode(IOBinding.encoding) + source = '# -*- coding: %s -*-\n%s' % ( + IOBinding.encoding, + source.encode(IOBinding.encoding)) except UnicodeError: self.tkconsole.resetoutput() self.write("Unsupported characters in input\n") diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py index 6ffc1b92a077..d023e2835b29 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -210,6 +210,8 @@ def cleanup_traceback(tb, exclude): fn, ln, nm, line = tb[i] if nm == '?': nm = "-toplevel-" + if fn.startswith("