[pypy-commit] pypy py3k: add getarg('y*'), use instead of bufferstr_w here

bdkearns noreply at buildbot.pypy.org
Sun May 4 00:45:23 CEST 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: py3k
Changeset: r71248:3360556c7eec
Date: 2014-05-03 18:44 -0400
http://bitbucket.org/pypy/pypy/changeset/3360556c7eec/

Log:	add getarg('y*'), use instead of bufferstr_w here

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1417,6 +1417,11 @@
             except TypeError:
                 pass
             self._getarg_error("read-write buffer", w_obj)
+        elif code == 'y*':
+            try:
+                return w_obj.buffer_w(self, self.BUF_SIMPLE)
+            except TypeError:
+                self._getarg_error("bytes or buffer", w_obj)
         else:
             assert False
 
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
@@ -711,7 +711,7 @@
     def write_w(self, space, w_data):
         self._check_init(space)
         self._check_closed(space, "write to closed file")
-        data = space.bufferstr_w(w_data)
+        data = space.getarg_w('y*', w_data).as_str()
         size = len(data)
 
         with self.lock:
diff --git a/pypy/module/_io/interp_fileio.py b/pypy/module/_io/interp_fileio.py
--- a/pypy/module/_io/interp_fileio.py
+++ b/pypy/module/_io/interp_fileio.py
@@ -340,7 +340,7 @@
     def write_w(self, space, w_data):
         self._check_closed(space)
         self._check_writable(space)
-        data = space.bufferstr_w(w_data)
+        data = space.getarg_w('y*', w_data).as_str()
 
         try:
             n = os.write(self.fd, data)


More information about the pypy-commit mailing list