]> granicus.if.org Git - python/commitdiff
Issue #7163: Propagate return value of sys.stdout.write.
authorMartin v. Löwis <martin@v.loewis.de>
Wed, 25 Jul 2012 09:32:26 +0000 (11:32 +0200)
committerMartin v. Löwis <martin@v.loewis.de>
Wed, 25 Jul 2012 09:32:26 +0000 (11:32 +0200)
Patch by Roger Serwy.

Lib/idlelib/NEWS.txt
Lib/idlelib/OutputWindow.py
Lib/idlelib/PyShell.py

index ed9e105949fa4076192d8338c9b676544bc93f84..3a641a019eb973a7a9abcdcc3baf86b2c8e48670 100644 (file)
@@ -1,6 +1,8 @@
 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 #13532, #15319: Check that arguments to sys.stdout.write are strings.
index 565cc9b772d8228535e2b131e367dd56b45d2fb2..cba9013997660dc161521816ba01bbe5dceb9e46 100644 (file)
@@ -40,6 +40,7 @@ class OutputWindow(EditorWindow):
         self.text.insert(mark, s, tags)
         self.text.see(mark)
         self.text.update()
+        return len(s)
 
     def writelines(self, lines):
         for line in lines:
index 83d40dff0bd2ba7b25bb23183146b8e925747773..0eae7c5cee38876a86af8e84c8cb48186e272437 100644 (file)
@@ -760,7 +760,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
 
     def write(self, s):
         "Override base class method"
-        self.tkconsole.stderr.write(s)
+        return self.tkconsole.stderr.write(s)
 
     def display_port_binding_error(self):
         tkMessageBox.showerror(
@@ -1229,7 +1229,7 @@ class PyShell(OutputWindow):
     def write(self, s, tags=()):
         try:
             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")
         except:
             raise ###pass  # ### 11Aug07 KBK if we are expecting exceptions
@@ -1238,6 +1238,7 @@ class PyShell(OutputWindow):
             self.canceled = 0
             if not use_subprocess:
                 raise KeyboardInterrupt
+        return count
 
 class PseudoFile(object):
 
@@ -1249,7 +1250,7 @@ class PseudoFile(object):
     def write(self, s):
         if not isinstance(s, str):
             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):
         for line in lines: