1. Pypy
  2. Untitled project
  3. pypy


wlav  committed 4b806e5 Merge

merge reflex-support into default: fixes for new buffer interfaces

  • Participants
  • Parent commits a55bcb4, b95344d
  • Branches default

Comments (4)

    1. wlav author


      not sure; but the latest changes to buffer broke the use of buffer_w for me (can't pass an array in, as it has no buffer), whereas readbuf_w works fine. Give that the release is imminent, having something that works has my preference ...

      Cheers, Wim

      1. Brian Kearns

        Yes, this is how it is in CPython -- array only has the old buffer interface, memoryview only has the new, as it now is in PyPy. Code that wants to accept both should probably use getarg_w('s*') or similar.

        Is this tested in cppyy/test? I don't see where.

        1. wlav author


          it's in cppyy/test/test_datatypes.py, which don't run as they require reflex installed. I'm working on a dummy_backend that hard-wires the reflex responses, so that some of these tests can run anyway. (You've seen that pass by. :) )

          I'll give getarg_w('s*') a try. From a quick look at baseobjspace.py, I'd say that looks good.

          Cheers, Wim

Files changed (2)

File pypy/module/cppyy/converter.py

View file
 def get_rawbuffer(space, w_obj):
     # raw buffer
-        buf = space.buffer_w(w_obj, space.BUF_SIMPLE)
+        buf = space.readbuf_w(w_obj)
         return rffi.cast(rffi.VOIDP, buf.get_raw_address())
     except Exception:
     def to_memory(self, space, w_obj, w_value, offset):
         # copy the full array (uses byte copy for now)
         address = rffi.cast(rffi.CCHARP, self._get_raw_address(space, w_obj, offset))
-        buf = space.buffer_w(w_value, space.BUF_SIMPLE)
+        buf = space.readbuf_w(w_value)
         # TODO: report if too many items given?
         for i in range(min(self.size*self.typesize, buf.getlength())):
             address[i] = buf.getitem(i)
         # copy only the pointer value
         rawobject = get_rawobject_nonnull(space, w_obj)
         byteptr = rffi.cast(rffi.CCHARPP, capi.direct_ptradd(rawobject, offset))
-        buf = space.buffer_w(w_value, space.BUF_SIMPLE)
+        buf = space.readbuf_w(w_value)
             byteptr[0] = buf.get_raw_address()
         except ValueError:

File pypy/module/cppyy/test/test_zjit.py

View file
         class dummy: pass
         self.config = dummy()
         self.config.translating = False
+        self.BUF_SIMPLE = 1
     def issequence_w(self, w_obj):
         return True
         return w_obj
     interp_w._annspecialcase_ = 'specialize:arg(1)'
-    def buffer_w(self, w_obj):
+    def buffer_w(self, w_obj, flags):
+        return FakeBuffer(w_obj)
+    def readbuf_w(self, w_obj):
         return FakeBuffer(w_obj)
     def exception_match(self, typ, sub):