@@ -200,6 +200,42 @@ def EnumWindowsCallbackFunc(hwnd, lParam):
200200
201201 windll .user32 .EnumWindows (EnumWindowsCallbackFunc , 0 )
202202
203+ def test_callback_register_int (self ):
204+ # Issue #8275: buggy handling of callback args under Win64
205+ # NOTE: should be run on release builds as well
206+ dll = CDLL (_ctypes_test .__file__ )
207+ CALLBACK = CFUNCTYPE (c_int , c_int , c_int , c_int , c_int , c_int )
208+ # All this function does is call the callback with its args squared
209+ func = dll ._testfunc_cbk_reg_int
210+ func .argtypes = (c_int , c_int , c_int , c_int , c_int , CALLBACK )
211+ func .restype = c_int
212+
213+ def callback (a , b , c , d , e ):
214+ return a + b + c + d + e
215+
216+ result = func (2 , 3 , 4 , 5 , 6 , CALLBACK (callback ))
217+ self .assertEqual (result , callback (2 * 2 , 3 * 3 , 4 * 4 , 5 * 5 , 6 * 6 ))
218+
219+ def test_callback_register_double (self ):
220+ # Issue #8275: buggy handling of callback args under Win64
221+ # NOTE: should be run on release builds as well
222+ dll = CDLL (_ctypes_test .__file__ )
223+ CALLBACK = CFUNCTYPE (c_double , c_double , c_double , c_double ,
224+ c_double , c_double )
225+ # All this function does is call the callback with its args squared
226+ func = dll ._testfunc_cbk_reg_double
227+ func .argtypes = (c_double , c_double , c_double ,
228+ c_double , c_double , CALLBACK )
229+ func .restype = c_double
230+
231+ def callback (a , b , c , d , e ):
232+ return a + b + c + d + e
233+
234+ result = func (1.1 , 2.2 , 3.3 , 4.4 , 5.5 , CALLBACK (callback ))
235+ self .assertEqual (result ,
236+ callback (1.1 * 1.1 , 2.2 * 2.2 , 3.3 * 3.3 , 4.4 * 4.4 , 5.5 * 5.5 ))
237+
238+
203239################################################################
204240
205241if __name__ == '__main__' :
0 commit comments