[pypy-svn] r73013 - in pypy/trunk/pypy/lib: _ctypes app_test/ctypes_tests
fijal at codespeak.net
fijal at codespeak.net
Sun Mar 28 03:37:04 CEST 2010
Author: fijal
Date: Sun Mar 28 03:37:03 2010
New Revision: 73013
Modified:
pypy/trunk/pypy/lib/_ctypes/function.py
pypy/trunk/pypy/lib/app_test/ctypes_tests/test_cast.py
Log:
A test and a fix
Modified: pypy/trunk/pypy/lib/_ctypes/function.py
==============================================================================
--- pypy/trunk/pypy/lib/_ctypes/function.py (original)
+++ pypy/trunk/pypy/lib/_ctypes/function.py Sun Mar 28 03:37:03 2010
@@ -359,6 +359,9 @@
# No output parameter, return the actual function result.
return retval
+ def __nonzero__(self):
+ return bool(self._buffer[0])
+
def __del__(self):
if self._needs_free:
# XXX we need to find a bad guy here
Modified: pypy/trunk/pypy/lib/app_test/ctypes_tests/test_cast.py
==============================================================================
--- pypy/trunk/pypy/lib/app_test/ctypes_tests/test_cast.py (original)
+++ pypy/trunk/pypy/lib/app_test/ctypes_tests/test_cast.py Sun Mar 28 03:37:03 2010
@@ -84,4 +84,6 @@
my_sqrt = lib.my_sqrt
sqrt = cast(cast(my_sqrt, c_void_p), CFUNCTYPE(c_double, c_double))
assert sqrt(4.0) == 2.0
+ assert not cast(0, CFUNCTYPE(c_int))
+
More information about the Pypy-commit
mailing list