]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#1288615: Python code.interact() and non-ASCII input
authorAntoine Pitrou <solipsis@pitrou.net>
Thu, 7 Aug 2008 18:42:40 +0000 (18:42 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Thu, 7 Aug 2008 18:42:40 +0000 (18:42 +0000)
Lib/code.py

index 6bdc658add03d8cea96ca87f7fbefbb86dc859f2..2e3ee11523bca16da31c49861e731c44b4b703a0 100644 (file)
@@ -232,6 +232,10 @@ class InteractiveConsole(InteractiveInterpreter):
                     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