[pypy-commit] pypy default: Merged in kostialopuhin/pypy/ctypes-byref (pull request #152)

arigo noreply at buildbot.pypy.org
Tue Jun 4 11:19:23 CEST 2013


Author: arigo <armin.rigo at gmail.com>
Branch: 
Changeset: r64748:aae5e8afa929
Date: 2013-06-04 11:18 +0200
http://bitbucket.org/pypy/pypy/changeset/aae5e8afa929/

Log:	Merged in kostialopuhin/pypy/ctypes-byref (pull request #152)

	Fix for getting ctypes.byref contents

diff --git a/lib_pypy/_ctypes/pointer.py b/lib_pypy/_ctypes/pointer.py
--- a/lib_pypy/_ctypes/pointer.py
+++ b/lib_pypy/_ctypes/pointer.py
@@ -120,6 +120,7 @@
         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)
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_pointers.py b/pypy/module/test_lib_pypy/ctypes_tests/test_pointers.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_pointers.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_pointers.py
@@ -108,6 +108,13 @@
 
             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)


More information about the pypy-commit mailing list