[pypy-issue] [issue1194] ctypes callbacks don't respect SystemExit
Amaury Forgeot d Arc
tracker at bugs.pypy.org
Thu Jun 28 20:11:56 CEST 2012
New submission from Amaury Forgeot d Arc <amauryfa at gmail.com>:
When a ctypes callback raises an exception, CPython uses PyErr_Print(), this has
the effect of
terminating the interpreter with a libc exit().
Yes, it's a bit abrupt, but some code relies on this behavior, and pypy should
do the same.
Here is an example, with CPython the callback is called only once:
from ctypes import *
libc = CDLL("libc.so.6")
qsort = libc.qsort
qsort.restype = None
CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
def py_cmp_func(a, b):
print "py_cmp_func", a, b
raise SystemExit("exit!")
cmp_func = CMPFUNC(py_cmp_func)
ia = (c_int * 5)(5, 1, 7, 33, 99)
qsort(ia, len(ia), sizeof(c_int), cmp_func)
----------
messages: 4511
nosy: afa, pypy-issue
priority: bug
status: unread
title: ctypes callbacks don't respect SystemExit
________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1194>
________________________________________
More information about the pypy-issue
mailing list