[pypy-commit] pypy default: provide space.w_buffer

bdkearns noreply at buildbot.pypy.org
Tue Mar 18 18:57:24 CET 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r70057:bf7b7094d768
Date: 2014-03-18 13:47 -0400
http://bitbucket.org/pypy/pypy/changeset/bf7b7094d768/

Log:	provide space.w_buffer

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -198,8 +198,7 @@
         w_impl = space.lookup(self, '__buffer__')
         if w_impl is not None:
             w_result = space.get_and_call_function(w_impl, self)
-            from pypy.module.__builtin__.interp_memoryview import W_Buffer
-            if isinstance(w_result, W_Buffer):
+            if space.isinstance_w(w_result, space.w_buffer):
                 return w_result.buf
         self._typed_unwrap_error(space, "buffer")
 
diff --git a/pypy/module/cpyext/bufferobject.py b/pypy/module/cpyext/bufferobject.py
--- a/pypy/module/cpyext/bufferobject.py
+++ b/pypy/module/cpyext/bufferobject.py
@@ -25,7 +25,7 @@
 @bootstrap_function
 def init_bufferobject(space):
     "Type description of PyBufferObject"
-    make_typedescr(space.gettypefor(W_Buffer).instancetypedef,
+    make_typedescr(space.w_buffer.instancetypedef,
                    basestruct=PyBufferObject.TO,
                    attach=buffer_attach,
                    dealloc=buffer_dealloc,
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -509,7 +509,7 @@
     # buffer protocol
     if space.is_w(w_type, space.w_str):
         setup_string_buffer_procs(space, pto)
-    if space.is_w(w_type, space.gettypefor(W_Buffer)):
+    if space.is_w(w_type, space.w_buffer):
         setup_buffer_buffer_procs(space, pto)
 
     pto.c_tp_free = llhelper(PyObject_Del.api_func.functype,
diff --git a/pypy/objspace/std/model.py b/pypy/objspace/std/model.py
--- a/pypy/objspace/std/model.py
+++ b/pypy/objspace/std/model.py
@@ -63,6 +63,7 @@
         from pypy.objspace.std import unicodeobject
         from pypy.objspace.std import dictproxyobject
         from pypy.objspace.std import proxyobject
+        from pypy.module.__builtin__.interp_memoryview import W_Buffer
         import pypy.objspace.std.default # register a few catch-all multimethods
 
         import pypy.objspace.std.marshal_impl # install marshal multimethods
@@ -82,6 +83,7 @@
         self.pythontypes.append(intobject.W_IntObject.typedef)
         self.pythontypes.append(boolobject.W_BoolObject.typedef)
         self.pythontypes.append(longobject.W_LongObject.typedef)
+        self.pythontypes.append(W_Buffer.typedef)
 
         # the set of implementation types
         self.typeorder = {


More information about the pypy-commit mailing list