[pypy-svn] pypy default: Fix write(buffer) on buffered io.

alex_gaynor commits-noreply at bitbucket.org
Mon Jan 31 04:01:55 CET 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r41484:2f9815943d4a
Date: 2011-01-30 22:01 -0500
http://bitbucket.org/pypy/pypy/changeset/2f9815943d4a/

Log:	Fix write(buffer) on buffered io.

diff --git a/pypy/module/_io/interp_bufferedio.py b/pypy/module/_io/interp_bufferedio.py
--- a/pypy/module/_io/interp_bufferedio.py
+++ b/pypy/module/_io/interp_bufferedio.py
@@ -613,7 +613,7 @@
     def write_w(self, space, w_data):
         self._check_init(space)
         self._check_closed(space, "write to closed file")
-        data = space.str_w(w_data)
+        data = space.bufferstr_w(w_data)
         size = len(data)
 
         with self.lock:

diff --git a/pypy/module/_io/test/test_io.py b/pypy/module/_io/test/test_io.py
--- a/pypy/module/_io/test/test_io.py
+++ b/pypy/module/_io/test/test_io.py
@@ -171,7 +171,12 @@
         a = array.array(b'i', range(10))
         n = len(a.tostring())
         with _io.open(self.tmpfile, "wb", 0) as f:
-            assert f.write(a) == n
+            res = f.write(a)
+            assert res == n
+
+        with _io.open(self.tmpfile, "wb") as f:
+            res = f.write(a)
+            assert res == n
 
     def test_attributes(self):
         import _io


More information about the Pypy-commit mailing list