[Patches] [ python-Patches-1232343 ] PyOS_Readline
SourceForge.net
noreply at sourceforge.net
Mon Jul 4 20:03:32 CEST 2005
Patches item #1232343, was opened at 2005-07-04 15:03
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1232343&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Lisandro Dalcin (dalcinl)
Assigned to: Nobody/Anonymous (nobody)
Summary: PyOS_Readline
Initial Comment:
Greg Lielens submitted some time ago a patch [id 955928] about
'PyOS_Readline()' behavior with non-interactive tty's. Basically,
there is no way to properly override 'PyOS_ReadlineFunctionPointer'
as
'PyOS_Readline()' calls 'PyOS_StdioReadline()' when 'stdin' or
'stdout' are not tty's. A snippet of "Parser/myreadline.c":
...
if (!isatty (fileno (sys_stdin)) || !isatty (fileno (sys_stdout)))
rv = PyOS_StdioReadline (sys_stdin, sys_stdout, prompt);
else
rv = (*PyOS_ReadlineFunctionPointer)(sys_stdin, sys_stdout,
prompt);
...
Greg Lielens is completely right about the problem, but his patch is
perhaps a bit crude, it also modifies "Python/bltinmodule.c" to solve
the same issue with 'raw_input'.
I think I have found a not so crude solution, and completely
backward
compatible. Basically, I moved 'isatty()' test from 'PyOS_Readline()'
in file "Parser/myreadline.c" to 'call_readline()' in file
"Modules/readline.c". In order to do that, I believe
'PyOS_StdioReadline' have to be added to file "Include/pythonrun.h".
All those changes will not affect in any way the behavior in
interactive sessions. Now 'PyOS_ReadlineFunctionPointer' can be
properly overrode and users of 'readline' module will not see any
change: in non-interactive tty's 'PyOS_StdioReadline()' will be called
anyway. The problem in 'input' and 'raw_input' builtins remains, but
its solution is not so clear to me, I think this part should not be
touched right now.
This patch passes 'Lib/test/regrtest.py' (of course, all those tests
are non-interactive!). I use Python interpreter every day in the
standard way and also in MPI-parallelized interactive sessions with
this patch applied, and I never have any problem.
I send my patch obtained with 'cvs diff -c' from current sources.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1232343&group_id=5470
More information about the Patches
mailing list