diff Lib/code.py @ 48191:f1fc947722f2 legacy-trunk

#1288615: Python code.interact() and non-ASCII input
author Antoine Pitrou <solipsis@pitrou.net>
date Thu, 07 Aug 2008 18:42:40 +0000
parents be7683a6f521
children 128dd6de134c
line wrap: on
line diff
--- a/Lib/code.py	Thu Aug 07 01:47:34 2008 +0000
+++ b/Lib/code.py	Thu Aug 07 18:42:40 2008 +0000
@@ -232,6 +232,10 @@
                     prompt = sys.ps1
                 try:
                     line = self.raw_input(prompt)
+                    # Can be None if sys.stdin was redefined
+                    encoding = getattr(sys.stdin, "encoding", None)
+                    if encoding and not isinstance(line, unicode):
+                        line = line.decode(encoding)
                 except EOFError:
                     self.write("\n")
                     break