[Python-Dev] PyOS_InputHook enhancement proposal

Keith Dart kdart at kdart.com
Fri Dec 10 04:41:19 CET 2004


Aahz wrote:
> On Thu, Dec 09, 2004, Michiel Jan Laurens de Hoon wrote:
> 
>>My suggestion is therefore to replace PyOS_InputHook by two functions
>>PyOS_AddInputHook and PyOS_RemoveInputHook, and let Python keep track of
>>which hooks are installed. This way, an extension module can add a hook
>>function without having to worry about other extension modules trying
>>to use the same hook.
>>
>>Any comments? Would I need to submit a PEP for this proposal?
> 
> 
> Because this is only for the C API, your best bet is to write a patch
> and submit it to SF.  If people whine or it gets rejected, then write a
> PEP.

I did modify the readline module that hooks this and can call back to a 
Python function. There are also methods for installing and removing the 
Python function. I did this for a different reason. I need Python signal 
handlers to run, and they don't run when the execution path is currently 
in some C code (such as readline). The hook forces the interpreter to 
run, and check for signals as a side effect. Using this I can be sitting 
in raw_input(), or interactive mode, and signal handlers are still run.

If you want it, let me know.

Actually, the modded readline module is part of pyNMS, on sourceforge.



-- 
                            \/ \/
                            (O O)
-- --------------------oOOo~(_)~oOOo----------------------------------------
Keith Dart <kdart at kdart.com>
vcard: <http://www.kdart.com/~kdart/kdart.vcf>
public key: ID: F3D288E4       URL: <http://www.kdart.com/~kdart/public.key>
============================================================================


More information about the Python-Dev mailing list