changeset: 96113:247f003b42ea branch: 2.7 parent: 96109:c473ac171041 user: Serhiy Storchaka date: Sun May 17 13:53:54 2015 +0300 files: Lib/idlelib/PyShell.py Lib/idlelib/run.py Misc/NEWS description: Issue #15809: IDLE shell now uses locale encoding instead of Latin1 for decoding unicode literals. diff -r c473ac171041 -r 247f003b42ea Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py Sat May 16 19:28:27 2015 -0400 +++ b/Lib/idlelib/PyShell.py Sun May 17 13:53:54 2015 +0300 @@ -34,6 +34,7 @@ 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 @@ 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 -r c473ac171041 -r 247f003b42ea Lib/idlelib/run.py --- a/Lib/idlelib/run.py Sat May 16 19:28:27 2015 -0400 +++ b/Lib/idlelib/run.py Sun May 17 13:53:54 2015 +0300 @@ -210,6 +210,8 @@ fn, ln, nm, line = tb[i] if nm == '?': nm = "-toplevel-" + if fn.startswith("