From: Antoine Pitrou Date: Thu, 7 Aug 2008 18:42:40 +0000 (+0000) Subject: #1288615: Python code.interact() and non-ASCII input X-Git-Tag: v2.6b3~120 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=74022ab0130c84ca3bbe567dccffaf4cd4cb0452;p=thirdparty%2FPython%2Fcpython.git #1288615: Python code.interact() and non-ASCII input --- diff --git a/Lib/code.py b/Lib/code.py index 6bdc658add03..2e3ee11523bc 100644 --- a/Lib/code.py +++ b/Lib/code.py @@ -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