Author: Armin Rigo <armin.r...@gmail.com> Branch: Changeset: r90197:6b02806984f7 Date: 2017-02-19 12:02 +0000 http://bitbucket.org/pypy/pypy/changeset/6b02806984f7/
Log: Merged in gmarkall/pypy/fix_bool_restype (pull request #516) Fix issue 2475: bool restypes not working 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 @@ -604,7 +604,8 @@ """ # hack for performance: if restype is a "simple" primitive type, don't # allocate the buffer because it's going to be thrown away immediately - if self._is_primitive(restype) and not restype._is_pointer_like(): + if (self._is_primitive(restype) and restype._type_ != '?' + and not restype._is_pointer_like()): return result # shape = restype._ffishape_ diff --git a/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py b/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py --- a/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py +++ b/pypy/module/test_lib_pypy/ctypes_tests/test_functions.py @@ -99,6 +99,15 @@ result = f(0, 0, 0, 0, 0, 0) assert result == '\x00' + def test_boolresult(self): + f = dll._testfunc_i_bhilfd + f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double] + f.restype = c_bool + false_result = f(0, 0, 0, 0, 0, 0) + assert false_result is False + true_result = f(1, 0, 0, 0, 0, 0) + assert true_result is True + def test_voidresult(self): f = dll._testfunc_v f.restype = None _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit