[Python-checkins] r65578 - python/trunk/Lib/code.py

antoine.pitrou python-checkins at python.org
Thu Aug 7 20:42:40 CEST 2008


Author: antoine.pitrou
Date: Thu Aug  7 20:42:40 2008
New Revision: 65578

Log:
#1288615: Python code.interact() and non-ASCII input



Modified:
   python/trunk/Lib/code.py

Modified: python/trunk/Lib/code.py
==============================================================================
--- python/trunk/Lib/code.py	(original)
+++ python/trunk/Lib/code.py	Thu Aug  7 20:42:40 2008
@@ -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


More information about the Python-checkins mailing list