summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/run.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2012-07-09 18:51:45 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2012-07-09 18:51:45 (GMT)
commitb7439a547b5d21bb32693eece2a8307d6221282e (patch)
treef7b3e7eb70731a3ecbf29d2d0d46654c41a10eae /Lib/idlelib/run.py
parent5c453ce3a4152f04d6be06c539102fd7185180cc (diff)
parent79007fa05d1a4bb0553244b362f2ca378e0b331a (diff)
downloadcpython-b7439a547b5d21bb32693eece2a8307d6221282e.zip
cpython-b7439a547b5d21bb32693eece2a8307d6221282e.tar.gz
cpython-b7439a547b5d21bb32693eece2a8307d6221282e.tar.bz2
merge heads
Diffstat (limited to 'Lib/idlelib/run.py')
-rw-r--r--Lib/idlelib/run.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 7124c72..6c91ae4 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -1,4 +1,5 @@
import sys
+import io
import linecache
import time
import socket
@@ -257,6 +258,23 @@ class MyRPCServer(rpc.RPCServer):
quitting = True
thread.interrupt_main()
+class _RPCFile(io.TextIOBase):
+ """Wrapper class for the RPC proxy to typecheck arguments
+ that may not support pickling."""
+
+ def __init__(self, rpc):
+ super.__setattr__(self, 'rpc', rpc)
+
+ def __getattr__(self, name):
+ return getattr(self.rpc, name)
+
+ def __setattr__(self, name, value):
+ return setattr(self.rpc, name, value)
+
+ def write(self, s):
+ if not isinstance(s, str):
+ raise TypeError('must be str, not ' + type(s).__name__)
+ return self.rpc.write(s)
class MyHandler(rpc.RPCHandler):
@@ -264,9 +282,9 @@ class MyHandler(rpc.RPCHandler):
"""Override base method"""
executive = Executive(self)
self.register("exec", executive)
- sys.stdin = self.console = self.get_remote_proxy("stdin")
- sys.stdout = self.get_remote_proxy("stdout")
- sys.stderr = self.get_remote_proxy("stderr")
+ sys.stdin = self.console = _RPCFile(self.get_remote_proxy("stdin"))
+ sys.stdout = _RPCFile(self.get_remote_proxy("stdout"))
+ sys.stderr = _RPCFile(self.get_remote_proxy("stderr"))
sys.displayhook = rpc.displayhook
# page help() text to shell.
import pydoc # import must be done here to capture i/o binding