[pypy-commit] pypy py3k: More wrapbytes in the io module.

amauryfa noreply at buildbot.pypy.org
Fri Oct 14 00:52:46 CEST 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r48041:29eb69170a85
Date: 2011-10-14 00:52 +0200
http://bitbucket.org/pypy/pypy/changeset/29eb69170a85/

Log:	More wrapbytes in the io module.

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
@@ -314,7 +314,7 @@
         self._writer_reset_buf()
 
     def _write(self, space, data):
-        w_data = space.wrap(data)
+        w_data = space.wrapbytes(data)
         w_written = space.call_method(self.w_raw, "write", w_data)
         written = space.getindex_w(w_written, space.w_IOError)
         if not 0 <= written <= len(data):
@@ -379,7 +379,7 @@
         else:
             raise OperationError(space.w_ValueError, space.wrap(
                 "read length must be positive or -1"))
-        return space.wrap(res)
+        return space.wrapbytes(res)
 
     @unwrap_spec(size=int)
     def peek_w(self, space, size=0):
@@ -396,7 +396,7 @@
             have = self._readahead()
             if have > 0:
                 data = ''.join(self.buffer[self.pos:self.pos+have])
-                return space.wrap(data)
+                return space.wrapbytes(data)
 
             # Fill the buffer from the raw stream, and copy it to the result
             self._reader_reset_buf()
@@ -406,7 +406,7 @@
                 size = 0
             self.pos = 0
             data = ''.join(self.buffer[:size])
-            return space.wrap(data)
+            return space.wrapbytes(data)
 
     @unwrap_spec(size=int)
     def read1_w(self, space, size):
@@ -417,7 +417,7 @@
             raise OperationError(space.w_ValueError, space.wrap(
                 "read length must be positive"))
         if size == 0:
-            return space.wrap("")
+            return space.wrapbytes("")
 
         with self.lock:
             if self.writable:
@@ -445,7 +445,7 @@
             endpos = self.pos + size
             data = ''.join(self.buffer[self.pos:endpos])
             self.pos = endpos
-            return space.wrap(data)
+            return space.wrapbytes(data)
 
     def _read_all(self, space):
         "Read all the file, don't update the cache"
@@ -476,7 +476,7 @@
             current_size += size
             if self.abs_pos != -1:
                 self.abs_pos += size
-        return space.wrap(builder.build())
+        return space.wrapbytes(builder.build())
 
     def _raw_read(self, space, buffer, start, length):
         length = intmask(length)
diff --git a/pypy/module/_io/interp_iobase.py b/pypy/module/_io/interp_iobase.py
--- a/pypy/module/_io/interp_iobase.py
+++ b/pypy/module/_io/interp_iobase.py
@@ -164,7 +164,7 @@
                 length = space.len_w(w_readahead)
                 if length > 0:
                     n = 0
-                    buf = space.str_w(w_readahead)
+                    buf = space.bytes_w(w_readahead)
                     if limit >= 0:
                         while True:
                             if n >= length or n >= limit:
@@ -187,7 +187,7 @@
                     space.w_IOError,
                     "peek() should have returned a bytes object, "
                     "not '%s'", space.type(w_read).getname(space))
-            read = space.str_w(w_read)
+            read = space.bytes_w(w_read)
             if not read:
                 break
 
@@ -197,7 +197,7 @@
             if read[-1] == '\n':
                 break
 
-        return space.wrap(builder.build())
+        return space.wrapbytes(builder.build())
 
     def readlines_w(self, space, w_hint=None):
         hint = convert_size(space, w_hint)
@@ -286,11 +286,11 @@
             if not space.isinstance_w(w_data, space.w_str):
                 raise OperationError(space.w_TypeError, space.wrap(
                     "read() should return bytes"))
-            data = space.str_w(w_data)
+            data = space.bytes_w(w_data)
             if not data:
                 break
             builder.append(data)
-        return space.wrap(builder.build())
+        return space.wrapbytes(builder.build())
 
 W_RawIOBase.typedef = TypeDef(
     '_RawIOBase', W_IOBase.typedef,


More information about the pypy-commit mailing list