Source

cffi / cffi / backend_ctypes.py

The branch 'release-0.2' does not exist.
Diff from to

cffi/backend_ctypes.py

     def __init__(self, *args):
         raise TypeError("cannot instantiate %r" % (self.__class__,))
 
+    @classmethod
+    def _newp(cls, init):
+        raise TypeError("expected a pointer or array ctype, got '%s'"
+                        % (cls._get_c_name(),))
+
     @staticmethod
     def _to_ctypes(value):
         raise TypeError
 class CTypesGenericArray(CTypesData):
     __slots__ = []
 
+    @classmethod
+    def _newp(cls, init):
+        return cls(init)
+
     def __iter__(self):
         for i in xrange(len(self)):
             yield self[i]
     _automatic_casts = False
 
     @classmethod
+    def _newp(cls, init):
+        return cls(init)
+
+    @classmethod
     def _cast_from(cls, source):
         if source is None:
             address = 0
         return BType._offsetof(fieldname)
 
     def newp(self, BType, source):
-        return BType(source)
+        return BType._newp(source)
 
     def cast(self, BType, source):
         return BType._cast_from(source)