Commits

Konstantin Lopuhin committed cb8c146

test and fix for getting ctypes.byref contents

Comments (0)

Files changed (2)

lib_pypy/_ctypes/pointer.py

         return self._buffer[0] != 0
 
     contents = property(getcontents, setcontents)
+    _obj = property(getcontents) # byref interface
 
     def _as_ffi_pointer_(self, ffitype):
         return as_ffi_pointer(self, ffitype)

pypy/module/test_lib_pypy/ctypes_tests/test_pointers.py

 
             py.test.raises(TypeError, delitem, p, 0)
 
+    def test_byref(self):
+        for ct, pt in zip(ctype_types, python_types):
+            i = ct(42)
+            p = byref(i)
+            assert type(p._obj) is ct
+            assert p._obj.value == 42
+
     def test_pointer_to_pointer(self):
         x = c_int(32)
         y = c_int(42)