Patches item #1367628, was opened at 2005-11-27 18:34 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=1367628&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: Gregory Lielens (greglielens) Assigned to: Nobody/Anonymous (nobody) Summary: use PyOS_ReadlineFunctionPointer in non-interractive input Initial Comment: Python provide a nice input hook for overiding it's input mechanism: User can define set PyOS_ReadlineFunctionPointer to point to an input function, and this function will be used instead of the default input function (PyOS_StdioReadline, or vms__StdioReadline for VMS). This mechanism can be very handy when implementing a parallel python interpreter: the main process can simply brodcast to listening input functions its own input strings. However, the current implementation does not use the hook (PyOS_ReadlineFunctionPointer) when it detect that the input or output are non-interractive (non-tty), but instead call directly the default implementation PyOS_StdioReadline. 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); ... This makes impossible to override the input behavior for non-interractive input. In particular, this prevent implementing parallel python interpreter because only the main python interpreter process have tty input/output, but even in non-parralel context I feel this uneccessarily limit the hook mechanism... I submitted a patch some time ago [id 955928], and Lisandro Dalcin submitted his own patch [id 1232343]to solve the same problem in the same context (parallel python interpreter). Since then, we collaborated for producing a single patch, cleaner than the previous ones. We also used input from the python-dev list [http://mail.python.org/pipermail/python-dev/2005-August/055761.html] and from the author of the VMS patch in PyOS_Readline (Jean-François Piéronne). This new patch thus replace the 2 precedent ones that should be marked as "duplicate". This patch passes 'Lib/test/regrtest.py' (of course, all those tests are non-interactive!). Lisandro and my company use this patched Python interpreter every day in the standard way and also in MPI-parallelized interactive sessions, and we never had any problem. The patch is relative to the current svn repository, and implement modification in Include/pythonrun.h, Parser/myreadline.c, Modules/readline.c and Python/bltinmodule.c. This last modification is needed for correcting the current behavior (not use the hook for non-interractive input/output) for the raw_input builtin. It is not needed for using the standard python interractive mode, but is needed if one want to use the ipython interpreter (or any interpreter implementing the input loop in python itself). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1367628&group_id=5470 _______________________________________________ Patches mailing list Patches@python.org http://mail.python.org/mailman/listinfo/patches