Ticket #70603: reproduction-steps.py

File reproduction-steps.py, 458 bytes (added by quintusdias (John G Evans), 5 weeks ago)

reproduction steps

Line 
1from ctypes import CFUNCTYPE, POINTER, c_int, CDLL, sizeof
2from ctypes.util import find_library
3
4path = find_library('c')
5libc = CDLL(path)
6
7IntArray5 = c_int * 5
8ia = IntArray5(5, 1, 7, 33, 99)
9qsort = libc.qsort
10qsort.restype = None
11
12
13CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
14
15def py_cmp_func(a, b):
16    print("py_cmp_func", a[0], b[0])
17    return a[0] - b[0]
18
19cmp_func = CMPFUNC(py_cmp_func)
20
21qsort(ia, len(ia), sizeof(c_int), cmp_func)