[pypy-svn] r28826 - in pypy/dist/pypy/rpython/rctypes: . test

arigo at codespeak.net arigo at codespeak.net
Thu Jun 15 16:47:26 CEST 2006


Author: arigo
Date: Thu Jun 15 16:47:25 2006
New Revision: 28826

Modified:
   pypy/dist/pypy/rpython/rctypes/afunc.py
   pypy/dist/pypy/rpython/rctypes/test/test_rctypes.py
Log:
Test and fix for a corner case where a setup() was missing.


Modified: pypy/dist/pypy/rpython/rctypes/afunc.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/afunc.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/afunc.py	Thu Jun 15 16:47:25 2006
@@ -67,7 +67,9 @@
 
         def repr_for_ctype(ctype):
             s = SomeCTypesObject(ctype, SomeCTypesObject.MEMORYALIAS)
-            return hop.rtyper.getrepr(s)
+            r = hop.rtyper.getrepr(s)
+            r.setup()
+            return r
 
         args_r = []
         if getattr(cfuncptr, 'argtypes', None) is not None:
@@ -107,6 +109,7 @@
             s_res = SomeCTypesObject(cfuncptr.restype,
                                      SomeCTypesObject.OWNSMEMORY)
             r_res = hop.rtyper.getrepr(s_res)
+            r_res.setup()
             RESTYPE = r_res.ll_type
         else:
             RESTYPE = lltype.Void

Modified: pypy/dist/pypy/rpython/rctypes/test/test_rctypes.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/test/test_rctypes.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/test/test_rctypes.py	Thu Jun 15 16:47:25 2006
@@ -172,6 +172,13 @@
         res = interpret(test_testfunc_struct_pointer_id, [])
         assert res == 21 - 17
 
+    def test_specialize_None_as_null_pointer(self):
+        def fn():
+            res = testfunc_struct_pointer_id(None)
+            return bool(res)
+        res = interpret(fn, [])
+        assert res is False
+
     def test_specialize_swap(self):
         res = interpret(test_testfunc_swap, [])
         assert res == 4



More information about the Pypy-commit mailing list