Martin Panter added the comment: It looks like ctypes uses ffi_closure_alloc() to allocate an executable function on demand. So it should be possible for readline to also call libffi and do this, but certainly not trivial.
>>> from ctypes import * >>> @CFUNCTYPE(c_int, c_int, c_int) ... def operate_and_get_next(count, char): ... print("Boo!", count, char) ... return 0 ... >>> libreadline = CDLL("libreadline.so.6") >>> libreadline.rl_add_defun("operate-and-get-next", operate_and_get_next, >>> ord("O") & 0x1F) 0 >>> # Press Ctrl-O ==> Boo! 1 15 ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue22228> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com