[pypy-svn] r52979 - in pypy/dist/pypy/lib: _ctypes app_test/ctypes
fijal at codespeak.net
fijal at codespeak.net
Thu Mar 27 04:02:48 CET 2008
Author: fijal
Date: Thu Mar 27 04:02:46 2008
New Revision: 52979
Modified:
pypy/dist/pypy/lib/_ctypes/function.py
pypy/dist/pypy/lib/app_test/ctypes/test_callbacks.py
Log:
solve keepalive issue. Strange keepalive circle via function closure -> self.
Modified: pypy/dist/pypy/lib/_ctypes/function.py
==============================================================================
--- pypy/dist/pypy/lib/_ctypes/function.py (original)
+++ pypy/dist/pypy/lib/_ctypes/function.py Thu Mar 27 04:02:46 2008
@@ -54,7 +54,8 @@
restype = restype._ffiargshape
else:
restype = 'O' # void
- self._ptr = _rawffi.CallbackPtr(self._wrap_callable(argument),
+ self._ptr = _rawffi.CallbackPtr(self._wrap_callable(argument,
+ self.argtypes),
argtypes, restype)
self._needs_free = True
self._buffer = self._ptr.byptr()
@@ -70,11 +71,11 @@
else:
raise TypeError("Unknown constructor %s" % (argument,))
- def _wrap_callable(self, to_call):
+ def _wrap_callable(self, to_call, argtypes):
def f(*args):
- if self.argtypes:
+ if argtypes:
args = [argtype._CData_retval(argtype.from_address(arg)._buffer)
- for argtype, arg in zip(self.argtypes, args)]
+ for argtype, arg in zip(argtypes, args)]
return to_call(*args)
return f
Modified: pypy/dist/pypy/lib/app_test/ctypes/test_callbacks.py
==============================================================================
--- pypy/dist/pypy/lib/app_test/ctypes/test_callbacks.py (original)
+++ pypy/dist/pypy/lib/app_test/ctypes/test_callbacks.py Thu Mar 27 04:02:46 2008
@@ -2,7 +2,7 @@
import py
from support import BaseCTypesTestChecker
-class TestCallbacks:#(BaseCTypesTestChecker):
+class TestCallbacks(BaseCTypesTestChecker):
functype = CFUNCTYPE
## def tearDown(self):
@@ -108,7 +108,7 @@
################################################################
-class TestSampleCallbacks:#(BaseCTypesTestChecker):
+class TestSampleCallbacks(BaseCTypesTestChecker):
def test_integrate(self):
# Derived from some then non-working code, posted by David Foster
@@ -134,7 +134,7 @@
################################################################
-class TestMoreCallbacks:#(BaseCTypesTestChecker):
+class TestMoreCallbacks(BaseCTypesTestChecker):
def test_callback_with_struct_argument(self):
py.test.skip("WIP")
@@ -191,5 +191,3 @@
assert res == [1,2,3,4,5]
-def test_last():
- py.test.skip("XXX don't forget about leaks")
More information about the Pypy-commit
mailing list