Author: Armin Rigo <[email protected]>
Branch: cpyext-ext
Changeset: r84901:6cfa79ea0abf
Date: 2016-06-03 15:26 +0200
http://bitbucket.org/pypy/pypy/changeset/6cfa79ea0abf/

Log:    Translation fix. Also move another part of a function to be seen by
        the JIT.

diff --git a/pypy/module/_cffi_backend/cdataobj.py 
b/pypy/module/_cffi_backend/cdataobj.py
--- a/pypy/module/_cffi_backend/cdataobj.py
+++ b/pypy/module/_cffi_backend/cdataobj.py
@@ -222,7 +222,10 @@
                 w_value.get_array_length() == length):
                 # fast path: copying from exactly the correct type
                 with w_value as source:
-                    rffi.c_memcpy(target, source, ctitemsize * length)
+                    source = rffi.cast(rffi.VOIDP, source)
+                    target = rffi.cast(rffi.VOIDP, target)
+                    size = rffi.cast(rffi.SIZE_T, ctitemsize * length)
+                    rffi.c_memcpy(target, source, size)
                 return
         #
         # A fast path for <char[]>[0:N] = "somestring" or some bytearray.
diff --git a/pypy/module/_cffi_backend/ctypeptr.py 
b/pypy/module/_cffi_backend/ctypeptr.py
--- a/pypy/module/_cffi_backend/ctypeptr.py
+++ b/pypy/module/_cffi_backend/ctypeptr.py
@@ -51,12 +51,8 @@
             value = rffi.cast(rffi.CCHARP, value)
         return cdataobj.W_CData(space, value, self)
 
-    def _convert_array_from_listview(self, cdata, w_ob):
-        if self.ctitem.pack_list_of_items(cdata, w_ob):   # fast path
-            return
-        #
+    def _convert_array_from_listview(self, cdata, lst_w):
         space = self.space
-        lst_w = space.listview(w_ob)
         if self.length >= 0 and len(lst_w) > self.length:
             raise oefmt(space.w_IndexError,
                         "too many initializers for '%s' (got %d)",
@@ -70,7 +66,10 @@
         space = self.space
         if (space.isinstance_w(w_ob, space.w_list) or
             space.isinstance_w(w_ob, space.w_tuple)):
-            self._convert_array_from_listview(cdata, w_ob)
+            if self.ctitem.pack_list_of_items(cdata, w_ob):   # fast path
+                pass
+            else:
+                self._convert_array_from_listview(cdata, space.listview(w_ob))
         elif (self.can_cast_anything or
               (self.ctitem.is_primitive_integer and
                self.ctitem.size == rffi.sizeof(lltype.Char))):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to