Author: Antonio Cuni <[email protected]>
Branch:
Changeset: r46038:f65745081f3b
Date: 2011-07-28 15:14 +0200
http://bitbucket.org/pypy/pypy/changeset/f65745081f3b/
Log: free the temp buffers created by the _ffi function. Also, thanks to
the new automatic string conversion in _ffi, passing a python string
is now supported by the fast path
diff --git a/lib_pypy/_ctypes/function.py b/lib_pypy/_ctypes/function.py
--- a/lib_pypy/_ctypes/function.py
+++ b/lib_pypy/_ctypes/function.py
@@ -365,7 +365,10 @@
if self._flags_ & _rawffi.FUNCFLAG_USE_LASTERROR:
set_last_error(_rawffi.get_last_error())
#
- return self._build_result(self._restype_, result, newargs)
+ try:
+ return self._build_result(self._restype_, result, newargs)
+ finally:
+ funcptr.free_temp_buffers()
def _do_errcheck(self, result, args):
# The 'errcheck' protocol
diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_fastpath.py
b/pypy/module/test_lib_pypy/ctypes_tests/test_fastpath.py
--- a/pypy/module/test_lib_pypy/ctypes_tests/test_fastpath.py
+++ b/pypy/module/test_lib_pypy/ctypes_tests/test_fastpath.py
@@ -63,13 +63,10 @@
result = f(mystr, ord("b"))
assert result == "bcd"
- @py.test.mark.xfail
def test_strings(self):
f = dll.my_strchr
f.argtypes = [c_char_p, c_int]
f.restype = c_char_p
- # python strings need to be converted to c_char_p, but this is
- # supported only in the slow path so far
result = f("abcd", ord("b"))
assert result == "bcd"
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit