This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients Rosuav, berker.peksag, lelit, martin.panter, steven.daprano, twouters
Date 2016-06-23.00:50:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1466643047.83.0.153882025782.issue22228@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2016-06-23 00:50:48martin.pantersetrecipients: + martin.panter, twouters, steven.daprano, Rosuav, berker.peksag, lelit
2016-06-23 00:50:47martin.pantersetmessageid: <1466643047.83.0.153882025782.issue22228@psf.upfronthosting.co.za>
2016-06-23 00:50:47martin.panterlinkissue22228 messages
2016-06-23 00:50:46martin.pantercreate