[ python-Bugs-1030629 ] PyOS_InputHook broken
SourceForge.net
noreply at sourceforge.net
Tue Oct 19 11:20:05 CEST 2004
Bugs item #1030629, was opened at 2004-09-19 11:27
Message generated for change (Comment added) made by mwh
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1030629&group_id=5470
Category: Python Interpreter Core
Group: Python 2.4
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Michiel de Hoon (mdehoon)
Assigned to: Michael Hudson (mwh)
Summary: PyOS_InputHook broken
Initial Comment:
PyOS_InputHook is a pointer to a function to be called
periodically when Python is idle. It is used, for
example, to get messages delivered to graphics windows.
In Python 2.3.4, calling PyOS_InputHook was handled by
readline via
rl_event_hook = PyOS_InputHook;
...
p = readline(prompt);
The readline library takes care of calling
rl_event_hook (and hence PyOS_InputHook) ten times per
second while Python idles at the call to readline(prompt).
In Python 2.4a3, the call to readline is replaced by a
call to readline_until_enter_or_signal. Here, the
"select" function is used:
has_input = select(fileno(rl_instream) + 1, &selectset,
NULL, NULL, NULL);
if(has_input > 0) {
rl_callback_read_char();
}
Now Python idles at "select", but PyOS_InputHook is not
being called. Instead, PyOS_InputHook gets called via
rl_event_hook at rl_callback_read_char. This means that
PyOS_InputHook is called once for every character the
user types, and is not called at all if the user is not
typing something.
----------------------------------------------------------------------
>Comment By: Michael Hudson (mwh)
Date: 2004-10-19 10:20
Message:
Logged In: YES
user_id=6656
Glad to help.
Windows is *so* not my problem :) Readline isn't used there,
anyway (except for cygwin).
----------------------------------------------------------------------
Comment By: Michiel de Hoon (mdehoon)
Date: 2004-10-19 10:08
Message:
Logged In: YES
user_id=488897
Sorry for my late reply, I was out of town last week. I
tested the updated readline.c (using Python 2.4b1) and found
no problems on Cygwin, Linux, and Mac OS X. On Windows
(using the installer from the Python website),
PyOS_InputHook is still being called once for every command
by the user. However, this was also the case in older
versions of Python, and by looking at the source it seems
that this problem is in Parser/myreadline.c instead of
Modules/readline.c (I submitted a separate patch for that).
Anyway, Modules/readline.c seems to be working fine. Thanks
for helping me out.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2004-10-07 14:47
Message:
Logged In: YES
user_id=6656
Ok, I made a couple of trivial changes, including moving the
rl_event_hook assignment. Seems to work for me.
Modules/readline.c revision 2.78.
Thanks for the patch!
----------------------------------------------------------------------
Comment By: Michiel de Hoon (mdehoon)
Date: 2004-10-07 13:21
Message:
Logged In: YES
user_id=488897
That is right. I didn't think about that. You might consider
assigning to rl_event_hook inside the second
readline_until_enter_or_signal (the one if not
defined(HAVE_RL_CALLBACK) && defined(HAVE_SELECT)), because
it is only needed there. Though it probably wouldn't hurt to
set rl_event_hook for both cases.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2004-10-07 13:10
Message:
Logged In: YES
user_id=6656
Oops, didn't see the patch. While I'm updating my checkout
and testing the patch, my first thought is that you probably
still want to assign to rl_event_hook, just in case we're
*not* using the callback interface to readline (old versions
of readline for example).
----------------------------------------------------------------------
Comment By: Michiel de Hoon (mdehoon)
Date: 2004-10-07 13:08
Message:
Logged In: YES
user_id=488897
I submitted a patch a couple of weeks ago. Let me know if
you can't find it on sourceforge.
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2004-10-07 12:20
Message:
Logged In: YES
user_id=6656
er, ping? i'm willing to believe this is a fairly bad bug, but i could
do with some encouragement to fix it :-)
----------------------------------------------------------------------
Comment By: Michael Hudson (mwh)
Date: 2004-09-19 19:35
Message:
Logged In: YES
user_id=6656
Well, this is probably my fault. However, I'm about to go on
holiday for a week and thinking about readline is definitely not
part of my plans :-)
Can you work up a patch for this? It shouldn't be terribly hard -- a
non-NULL fifth argument to select seems in order.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1030629&group_id=5470
More information about the Python-bugs-list
mailing list