Author: Brian Kearns <[email protected]>
Branch: 
Changeset: r63256:5fadf0b41675
Date: 2013-04-11 19:52 -0400
http://bitbucket.org/pypy/pypy/changeset/5fadf0b41675/

Log:    test and fix for BytesIO.write() return value

diff --git a/pypy/module/_io/interp_bytesio.py 
b/pypy/module/_io/interp_bytesio.py
--- a/pypy/module/_io/interp_bytesio.py
+++ b/pypy/module/_io/interp_bytesio.py
@@ -96,7 +96,7 @@
         buf = space.buffer_w(w_data)
         length = buf.getlength()
         if length <= 0:
-            return
+            return space.wrap(0)
 
         if self.pos + length > len(self.buf):
             self.buf.extend(['\0'] * (self.pos + length - len(self.buf)))
diff --git a/pypy/module/_io/test/test_bytesio.py 
b/pypy/module/_io/test/test_bytesio.py
--- a/pypy/module/_io/test/test_bytesio.py
+++ b/pypy/module/_io/test/test_bytesio.py
@@ -24,6 +24,7 @@
     def test_write(self):
         import _io
         f = _io.BytesIO()
+        assert f.write("") == 0
         assert f.write("hello") == 5
         import gc; gc.collect()
         assert f.getvalue() == "hello"
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to