Commits

Antonio Cuni committed 0cffbb8

a failing test and the corresponding fix. I hate RPython, this corresponds to a segfault after translation :-/

  • Participants
  • Parent commits 4a5a1fe
  • Branches fast_cffi_list_init

Comments (0)

Files changed (2)

pypy/module/_cffi_backend/ctypeptr.py

     def is_char_or_unichar_ptr_or_array(self):
         return isinstance(self.ctitem, ctypeprim.W_CTypePrimitiveCharOrUniChar)
 
+    def aslist_int(self, cdata):
+        return None
+
+    def aslist_float(self, cdata):
+        return None
+
     def cast(self, w_ob):
         # cast to a pointer, to a funcptr, or to an array.
         # Note that casting to an array is an extension to the C language,

pypy/module/_cffi_backend/test/test_fastpath.py

         if not self.runappdirect:
             assert self.get_count() == 1
 
+    def test_TypeError_if_no_length(self):
+        import _cffi_backend
+        LONG = _cffi_backend.new_primitive_type('long')
+        P_LONG = _cffi_backend.new_pointer_type(LONG)
+        LONG_ARRAY = _cffi_backend.new_array_type(P_LONG, 3)
+        buf = _cffi_backend.newp(LONG_ARRAY)
+        pbuf = _cffi_backend.cast(P_LONG, buf)
+        raises(TypeError, "list(pbuf)")
+
+
     def test_list_float(self):
         import _cffi_backend
         DOUBLE = _cffi_backend.new_primitive_type('double')