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

Issue #7163: Propagate return value of sys.stdout.write.

Patch by Roger Serwy.
parent 514269f1
What's New in IDLE 3.2.4? What's New in IDLE 3.2.4?
========================= =========================
- Issue #7163: Propagate return value of sys.stdout.write.
- Issue #15318: Prevent writing to sys.stdin. - Issue #15318: Prevent writing to sys.stdin.
- Issue #13532, #15319: Check that arguments to sys.stdout.write are strings. - Issue #13532, #15319: Check that arguments to sys.stdout.write are strings.
......
...@@ -40,6 +40,7 @@ class OutputWindow(EditorWindow): ...@@ -40,6 +40,7 @@ class OutputWindow(EditorWindow):
self.text.insert(mark, s, tags) self.text.insert(mark, s, tags)
self.text.see(mark) self.text.see(mark)
self.text.update() self.text.update()
return len(s)
def writelines(self, lines): def writelines(self, lines):
for line in lines: for line in lines:
......
...@@ -760,7 +760,7 @@ class ModifiedInterpreter(InteractiveInterpreter): ...@@ -760,7 +760,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
def write(self, s): def write(self, s):
"Override base class method" "Override base class method"
self.tkconsole.stderr.write(s) return self.tkconsole.stderr.write(s)
def display_port_binding_error(self): def display_port_binding_error(self):
tkMessageBox.showerror( tkMessageBox.showerror(
...@@ -1229,7 +1229,7 @@ class PyShell(OutputWindow): ...@@ -1229,7 +1229,7 @@ class PyShell(OutputWindow):
def write(self, s, tags=()): def write(self, s, tags=()):
try: try:
self.text.mark_gravity("iomark", "right") self.text.mark_gravity("iomark", "right")
OutputWindow.write(self, s, tags, "iomark") count = OutputWindow.write(self, s, tags, "iomark")
self.text.mark_gravity("iomark", "left") self.text.mark_gravity("iomark", "left")
except: except:
raise ###pass # ### 11Aug07 KBK if we are expecting exceptions raise ###pass # ### 11Aug07 KBK if we are expecting exceptions
...@@ -1238,6 +1238,7 @@ class PyShell(OutputWindow): ...@@ -1238,6 +1238,7 @@ class PyShell(OutputWindow):
self.canceled = 0 self.canceled = 0
if not use_subprocess: if not use_subprocess:
raise KeyboardInterrupt raise KeyboardInterrupt
return count
class PseudoFile(object): class PseudoFile(object):
...@@ -1249,7 +1250,7 @@ class PseudoFile(object): ...@@ -1249,7 +1250,7 @@ class PseudoFile(object):
def write(self, s): def write(self, s):
if not isinstance(s, str): if not isinstance(s, str):
raise TypeError('must be str, not ' + type(s).__name__) raise TypeError('must be str, not ' + type(s).__name__)
self.shell.write(s, self.tags) return self.shell.write(s, self.tags)
def writelines(self, lines): def writelines(self, lines):
for line in lines: for line in lines:
......
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