@@ -166,6 +166,42 @@ def func(x):
166166
167167 self .assertLess (diff , 0.01 , "%s not less than 0.01" % diff )
168168
169+ def test_callback_register_int (self ):
170+ # Issue #8275: buggy handling of callback args under Win64
171+ # NOTE: should be run on release builds as well
172+ dll = CDLL (_ctypes_test .__file__ )
173+ CALLBACK = CFUNCTYPE (c_int , c_int , c_int , c_int , c_int , c_int )
174+ # All this function does is call the callback with its args squared
175+ func = dll ._testfunc_cbk_reg_int
176+ func .argtypes = (c_int , c_int , c_int , c_int , c_int , CALLBACK )
177+ func .restype = c_int
178+
179+ def callback (a , b , c , d , e ):
180+ return a + b + c + d + e
181+
182+ result = func (2 , 3 , 4 , 5 , 6 , CALLBACK (callback ))
183+ self .assertEqual (result , callback (2 * 2 , 3 * 3 , 4 * 4 , 5 * 5 , 6 * 6 ))
184+
185+ def test_callback_register_double (self ):
186+ # Issue #8275: buggy handling of callback args under Win64
187+ # NOTE: should be run on release builds as well
188+ dll = CDLL (_ctypes_test .__file__ )
189+ CALLBACK = CFUNCTYPE (c_double , c_double , c_double , c_double ,
190+ c_double , c_double )
191+ # All this function does is call the callback with its args squared
192+ func = dll ._testfunc_cbk_reg_double
193+ func .argtypes = (c_double , c_double , c_double ,
194+ c_double , c_double , CALLBACK )
195+ func .restype = c_double
196+
197+ def callback (a , b , c , d , e ):
198+ return a + b + c + d + e
199+
200+ result = func (1.1 , 2.2 , 3.3 , 4.4 , 5.5 , CALLBACK (callback ))
201+ self .assertEqual (result ,
202+ callback (1.1 * 1.1 , 2.2 * 2.2 , 3.3 * 3.3 , 4.4 * 4.4 , 5.5 * 5.5 ))
203+
204+
169205################################################################
170206
171207if __name__ == '__main__' :
0 commit comments