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

arigo at codespeak.net arigo at codespeak.net
Thu Oct 18 09:30:05 CEST 2007


Author: arigo
Date: Thu Oct 18 09:30:04 2007
New Revision: 47525

Modified:
   pypy/dist/pypy/rpython/rctypes/rpointer.py
   pypy/dist/pypy/rpython/rctypes/test/test_rstringbuf.py
Log:
Fix this test, broken by the fact that we no longer ensure that
all variables stay alive until the end of the current block.

Add some (unrelated) missing keepalive logic in rpointer.


Modified: pypy/dist/pypy/rpython/rctypes/rpointer.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/rpointer.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/rpointer.py	Thu Oct 18 09:30:04 2007
@@ -57,8 +57,10 @@
         assert s_attr.const == 'contents'
         v_ptr = hop.inputarg(self, 0)
         v_c_ptr = self.getvalue(hop.llops, v_ptr)
+        v_owner = self.getkeepalive(hop.llops, v_ptr)
         hop.exception_cannot_occur()
-        return self.r_contents.allocate_instance_ref(hop.llops, v_c_ptr)
+        return self.r_contents.allocate_instance_ref(hop.llops, v_c_ptr,
+                                                     v_owner)
 
     def rtype_setattr(self, hop):
         s_attr = hop.args_s[1]

Modified: pypy/dist/pypy/rpython/rctypes/test/test_rstringbuf.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/test/test_rstringbuf.py	(original)
+++ pypy/dist/pypy/rpython/rctypes/test/test_rstringbuf.py	Thu Oct 18 09:30:04 2007
@@ -16,6 +16,7 @@
 from ctypes import c_char_p, c_long, pointer, sizeof, c_int
 from pypy.rpython.rctypes.astringbuf import StringBufferType
 from pypy.rlib.rarithmetic import r_uint
+from pypy.rlib.objectmodel import keepalive_until_here
 
 
 class Test_annotation:
@@ -221,7 +222,9 @@
             for i in range(sizeof(c_long)):
                 buf[i] = c_n_ptr[i]
             c_long_ptr = cast(buf, POINTER(c_long))
-            return c_long_ptr.contents.value
+            res = c_long_ptr.contents.value
+            keepalive_until_here(buf)
+            return res
         fn = compile(func, [int])
         res = fn(0x12345678)
         assert res == 0x12345678



More information about the Pypy-commit mailing list