[pypy-commit] pypy refactor-buffer-api: kill rarely used bufferstr_new_w func

bdkearns noreply at buildbot.pypy.org
Tue Apr 22 20:34:00 CEST 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: refactor-buffer-api
Changeset: r70858:d6324ad0ee46
Date: 2014-03-19 02:50 -0400
http://bitbucket.org/pypy/pypy/changeset/d6324ad0ee46/

Log:	kill rarely used bufferstr_new_w func

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1333,13 +1333,6 @@
                                  self.wrap('read-write buffer expected'))
         return buffer
 
-    def bufferstr_new_w(self, w_obj):
-        # Implement the "new buffer interface" (new in Python 2.7)
-        # returning an unwrapped string. It doesn't accept unicode
-        # strings
-        buffer = self.buffer_w(w_obj)
-        return buffer.as_str()
-
     def bufferstr_w(self, w_obj):
         # Directly returns an interp-level str.  Note that if w_obj is a
         # unicode string, this is different from str_w(buffer(w_obj)):
diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -53,7 +53,7 @@
         return space.bufferstr_w(self)
 
     def _op_val(self, space, w_other):
-        return space.bufferstr_new_w(w_other)
+        return space.buffer_w(w_other).as_str()
 
     def _chr(self, char):
         assert len(char) == 1
@@ -432,12 +432,12 @@
 def makebytearraydata_w(space, w_source):
     # String-like argument
     try:
-        string = space.bufferstr_new_w(w_source)
+        buf = space.buffer_w(w_source)
     except OperationError as e:
         if not e.match(space, space.w_TypeError):
             raise
     else:
-        return [c for c in string]
+        return [c for c in buf.as_str()]
 
     # sequence of bytes
     w_iter = space.iter(w_source)
@@ -1055,7 +1055,7 @@
 
         if data and i != 0:
             newdata.extend(data)
-        newdata.extend([c for c in space.bufferstr_new_w(w_s)])
+        newdata.extend([c for c in space.buffer_w(w_s).as_str()])
     return W_BytearrayObject(newdata)
 
 _space_chars = ''.join([chr(c) for c in [9, 10, 11, 12, 13, 32]])


More information about the pypy-commit mailing list