Ticket #70603: reproduction-steps.py
File reproduction-steps.py, 458 bytes (added by quintusdias (John G Evans), 3 months ago) |
---|
Line | |
---|---|
1 | from ctypes import CFUNCTYPE, POINTER, c_int, CDLL, sizeof |
2 | from ctypes.util import find_library |
3 | |
4 | path = find_library('c') |
5 | libc = CDLL(path) |
6 | |
7 | IntArray5 = c_int * 5 |
8 | ia = IntArray5(5, 1, 7, 33, 99) |
9 | qsort = libc.qsort |
10 | qsort.restype = None |
11 | |
12 | |
13 | CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int)) |
14 | |
15 | def py_cmp_func(a, b): |
16 | print("py_cmp_func", a[0], b[0]) |
17 | return a[0] - b[0] |
18 | |
19 | cmp_func = CMPFUNC(py_cmp_func) |
20 | |
21 | qsort(ia, len(ia), sizeof(c_int), cmp_func) |