summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2003-06-22 07:52:56 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2003-06-22 07:52:56 (GMT)
commitbcc651a1f954bad7a14d93d41e95728072e48ea0 (patch)
tree92941fd13a92cf19a27aaf974db4398d5d03290e /Lib
parentfaa697a5c9f36ee410599740deb047b8b8c56482 (diff)
downloadcpython-bcc651a1f954bad7a14d93d41e95728072e48ea0.zip
cpython-bcc651a1f954bad7a14d93d41e95728072e48ea0.tar.gz
cpython-bcc651a1f954bad7a14d93d41e95728072e48ea0.tar.bz2
Idlefork patch #682347: convert Unicode strings from readline to
IOBinding.encoding. Also set sys.std{in,out,err}.encoding, for both the local and the subprocess case.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/idlelib/PyShell.py16
-rw-r--r--Lib/idlelib/run.py3
2 files changed, 15 insertions, 4 deletions
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index 3478004..83f2de8 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -741,9 +741,10 @@ class PyShell(OutputWindow):
self.save_stdout = sys.stdout
self.save_stderr = sys.stderr
self.save_stdin = sys.stdin
- self.stdout = PseudoFile(self, "stdout")
- self.stderr = PseudoFile(self, "stderr")
- self.console = PseudoFile(self, "console")
+ import IOBinding
+ self.stdout = PseudoFile(self, "stdout", IOBinding.encoding)
+ self.stderr = PseudoFile(self, "stderr", IOBinding.encoding)
+ self.console = PseudoFile(self, "console", IOBinding.encoding)
if not use_subprocess:
sys.stdout = self.stdout
sys.stderr = self.stderr
@@ -886,6 +887,12 @@ class PyShell(OutputWindow):
finally:
self.reading = save
line = self.text.get("iomark", "end-1c")
+ if isinstance(line, unicode):
+ import IOBinding
+ try:
+ line = line.encode(IOBinding.encoding)
+ except UnicodeError:
+ pass
self.resetoutput()
if self.canceled:
self.canceled = 0
@@ -1090,10 +1097,11 @@ class PyShell(OutputWindow):
class PseudoFile:
- def __init__(self, shell, tags):
+ def __init__(self, shell, tags, encoding=None):
self.shell = shell
self.tags = tags
self.softspace = 0
+ self.encoding = encoding
def write(self, s):
self.shell.write(s, self.tags)
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index be91d54..4e6345c 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -210,6 +210,9 @@ class MyHandler(rpc.RPCHandler):
sys.stdin = self.console = self.get_remote_proxy("stdin")
sys.stdout = self.get_remote_proxy("stdout")
sys.stderr = self.get_remote_proxy("stderr")
+ import IOBinding
+ sys.stdin.encoding = sys.stdout.encoding = \
+ sys.stderr.encoding = IOBinding.encoding
self.interp = self.get_remote_proxy("interp")
rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05)