mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
merge 3.2
This commit is contained in:
commit
79007fa05d
3 changed files with 25 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue