[Patches] [ python-Patches-462122 ] add readline startup and pre_event hooks

noreply@sourceforge.net noreply@sourceforge.net
Sun, 30 Sep 2001 14:16:18 -0700


Patches item #462122, was opened at 2001-09-16 16:50
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=462122&group_id=5470

Category: Modules
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Matthew Mueller (donut)
Assigned to: Martin v. Löwis (loewis)
Summary: add readline startup and pre_event hooks

Initial Comment:
Adds support for the readline rl_startup_hook and
rl_pre_event_hook callbacks.  For example, the startup
hook can be used to insert text to begin editing rather
than always starting with a blank entry.  I just added
the pre_event hook too since it was there. 

Supporting rl_event_hook could be done too, but its
already set to PyOS_InputHook and I'm not sure what
significance this has or if it could just be called in
addition to that.
In order to avoid too much code dupe I moved some stuff
into a generic hook setter func.  However I'm not 100%
sure of the thread state stuff, if it really needs to
store a seperate one per each hook or if it should only
store one.



----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2001-09-30 14:16

Message:
Logged In: YES 
user_id=21627

Thanks for the patch, I've committed it as acconfig.h 1.57,
configure 1.254, configure.in 1.262, pyconfig.h.in 1.12,
libreadline.tex 1.7, NEWS 1.262, and readline.c 2.38.

The autoconf changes where necessary since readline supports
the pre_event_hook only since 4.0.

On thread changes: I think a single thread state should have
been enough. Furthermore, things are likely to go wrong when
the hook is set in a different thread than the one running
the readline hook. This has been a problem all the time.
IMO, it would not be necessary to allocate a thread state at
all; it would be sufficient to safe the interpreter, and
allocate a fresh thread state every time a callback is
invoked.

There is also the problem the onintr signal appearing in
another thread, resulting in a incorrect longjmp call. So I
left this to anybody revising the entire
readline-and-threads issue. 

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=462122&group_id=5470