[pypy-svn] pypy real-voidp: Fix test_rffi.py: when calling an external, any pointer is convertible to VOIDP

amauryfa commits-noreply at bitbucket.org
Mon Feb 28 11:32:33 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: real-voidp
Changeset: r42341:34bba670c8b5
Date: 2011-02-28 11:08 +0100
http://bitbucket.org/pypy/pypy/changeset/34bba670c8b5/

Log:	Fix test_rffi.py: when calling an external, any pointer is
	convertible to VOIDP

diff --git a/pypy/rpython/lltypesystem/lltype.py b/pypy/rpython/lltypesystem/lltype.py
--- a/pypy/rpython/lltypesystem/lltype.py
+++ b/pypy/rpython/lltypesystem/lltype.py
@@ -1178,6 +1178,7 @@
             return '* %s' % (self._obj0,)
 
     def __call__(self, *args):
+        from pypy.rpython.lltypesystem import rffi
         if isinstance(self._T, FuncType):
             if len(args) != len(self._T.ARGS):
                 raise TypeError,"calling %r with wrong argument number: %r" % (self._T, args)
@@ -1191,11 +1192,17 @@
                             pass
                         else:
                             assert a == value
+                    # Any pointer is convertible to void*
+                    elif (ARG is rffi.VOIDP and
+                          isinstance(typeOf(a), Ptr)):
+                        pass
                     # special case: ARG can be a container type, in which
                     # case a should be a pointer to it.  This must also be
                     # special-cased in the backends.
-                    elif not (isinstance(ARG, ContainerType)
-                            and typeOf(a) == Ptr(ARG)):
+                    elif (isinstance(ARG, ContainerType) and
+                          typeOf(a) == Ptr(ARG)):
+                        pass
+                    else:
                         args_repr = [typeOf(arg) for arg in args]
                         raise TypeError, ("calling %r with wrong argument "
                                           "types: %r" % (self._T, args_repr))


More information about the Pypy-commit mailing list