Convert characters from the locale's encoding on output.
Reject characters outside the locale's encoding on input.
diff --git a/Tools/idle/PyShell.py b/Tools/idle/PyShell.py
index 31a8940..e71a9a1 100644
--- a/Tools/idle/PyShell.py
+++ b/Tools/idle/PyShell.py
@@ -191,7 +191,12 @@
warnings.filterwarnings(action="error", category=SyntaxWarning)
if isinstance(source, types.UnicodeType):
import IOBinding
- source = source.encode(IOBinding.encoding)
+ try:
+ source = source.encode(IOBinding.encoding)
+ except UnicodeError:
+ self.tkconsole.resetoutput()
+ self.write("Unsupported characters in input")
+ return
try:
return InteractiveInterpreter.runsource(self, source, filename)
finally: