Commit e8e4e145 authored by Martin v. Löwis's avatar Martin v. Löwis

- Issue #13532: Check that arguments to sys.stdout.write are strings.

parent 45ed0124
What's New in IDLE 2.7.4? What's New in IDLE 2.7.4?
========================= =========================
- Issue #13532: Check that arguments to sys.stdout.write are strings.
- Issue # 12510: Attempt to get certain tool tips no longer crashes IDLE. - Issue # 12510: Attempt to get certain tool tips no longer crashes IDLE.
- Issue10365: File open dialog now works instead of crashing even when - Issue10365: File open dialog now works instead of crashing even when
......
...@@ -1265,6 +1265,8 @@ class PseudoFile(object): ...@@ -1265,6 +1265,8 @@ class PseudoFile(object):
self.encoding = encoding self.encoding = encoding
def write(self, s): def write(self, s):
if not isinstance(s, str):
raise TypeError('must be str, not ' + type(s).__name__)
self.shell.write(s, self.tags) self.shell.write(s, self.tags)
def writelines(self, lines): def writelines(self, lines):
......
import sys import sys
import io
import linecache import linecache
import time import time
import socket import socket
...@@ -248,6 +249,23 @@ class MyRPCServer(rpc.RPCServer): ...@@ -248,6 +249,23 @@ class MyRPCServer(rpc.RPCServer):
quitting = True quitting = True
thread.interrupt_main() 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): class MyHandler(rpc.RPCHandler):
...@@ -255,9 +273,9 @@ class MyHandler(rpc.RPCHandler): ...@@ -255,9 +273,9 @@ class MyHandler(rpc.RPCHandler):
"""Override base method""" """Override base method"""
executive = Executive(self) executive = Executive(self)
self.register("exec", executive) self.register("exec", executive)
sys.stdin = self.console = self.get_remote_proxy("stdin") sys.stdin = self.console = _RPCFile(self.get_remote_proxy("stdin"))
sys.stdout = self.get_remote_proxy("stdout") sys.stdout = _RPCFile(self.get_remote_proxy("stdout"))
sys.stderr = self.get_remote_proxy("stderr") sys.stderr = _RPCFile(self.get_remote_proxy("stderr"))
from idlelib import IOBinding from idlelib import IOBinding
sys.stdin.encoding = sys.stdout.encoding = \ sys.stdin.encoding = sys.stdout.encoding = \
sys.stderr.encoding = IOBinding.encoding sys.stderr.encoding = IOBinding.encoding
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment