]> granicus.if.org Git - python/commitdiff
Issue #15809: IDLE shell now uses locale encoding instead of Latin1 for
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 17 May 2015 10:53:54 +0000 (13:53 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 17 May 2015 10:53:54 +0000 (13:53 +0300)
decoding unicode literals.

Lib/idlelib/PyShell.py
Lib/idlelib/run.py
Misc/NEWS

index 17ca0ef3f80afde15d66b29df9b9abb5e088e775..8ee0c0e7466e972db2e403022789f44d204bd677 100755 (executable)
@@ -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")
index 6ffc1b92a07723fd9a9e351c5dd0871b2e8c864d..d023e2835b29e0abd48c807044f17ea812c2fa60 100644 (file)
@@ -210,6 +210,8 @@ def cleanup_traceback(tb, exclude):
         fn, ln, nm, line = tb[i]
         if nm == '?':
             nm = "-toplevel-"
+        if fn.startswith("<pyshell#") and IOBinding.encoding != 'utf-8':
+            ln -= 1  # correction for coding cookie
         if not line and fn.startswith("<pyshell#"):
             line = rpchandler.remotecall('linecache', 'getline',
                                               (fn, ln), {})
index c30fd14982142881a4afca6b2bd2f975a9a70257..05d609da3fa1db877b41fbe054846c1313643afa 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,6 +25,12 @@ Library
 
 - Issue #24134: Reverted issue #24134 changes.
 
+IDLE
+----
+
+- Issue #15809: IDLE shell now uses locale encoding instead of Latin1 for
+  decoding unicode literals.
+
 
 What's New in Python 2.7.10 release candidate 1?
 ================================================