[pypy-commit] pypy ffi-backend: Fix the convertion logic.

arigo noreply at buildbot.pypy.org
Wed Jul 4 05:16:10 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: ffi-backend
Changeset: r55913:65a606592cc1
Date: 2012-07-04 05:13 +0200
http://bitbucket.org/pypy/pypy/changeset/65a606592cc1/

Log:	Fix the convertion logic.

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
@@ -49,12 +49,15 @@
         if not isinstance(ob, cdataobj.W_CData):
             raise self._convert_error("compatible pointer", w_ob)
         other = ob.ctype
-        if (isinstance(other, W_CTypePtrOrArray) and
-             (self is other or
-              self.can_cast_anything or other.can_cast_anything)):
-            pass    # compatible types
-        else:
-            raise self._convert_error("compatible pointer", w_ob)
+        if not isinstance(other, W_CTypePtrBase):
+            from pypy.module._cffi_backend import ctypearray
+            if isinstance(other, ctypearray.W_CTypeArray):
+                other = other.ctptr
+            else:
+                raise self._convert_error("compatible pointer", w_ob)
+        if self is not other:
+            if not (self.can_cast_anything or other.can_cast_anything):
+                raise self._convert_error("compatible pointer", w_ob)
 
         rffi.cast(rffi.CCHARPP, cdata)[0] = ob._cdata
 


More information about the pypy-commit mailing list