This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Make the "python" command resemble the standard Python interpreter
- From: Doug Evans <dje at google dot com>
- To: Khoo Yit Phang <khooyp at cs dot umd dot edu>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 12 Jan 2012 08:40:27 -0800
- Subject: Re: Make the "python" command resemble the standard Python interpreter
- References: <A6FE1BE9-CD08-41A2-A1E8-F659140DA689@cs.umd.edu>
On Tue, Jan 10, 2012 at 4:18 PM, Khoo Yit Phang <khooyp@cs.umd.edu> wrote:
> Hi,
>
> I'd like to contribute a patch to improve the "python" command by making it resemble the standard Python interpreter in behavior.
>
> For "python" with arguments, this prints the results of expressions, e.g., "python 1 + 2" will print "3" (previously, it will not print anything).
>
> For "python" without arguments, this uses Python's built-in interactive loop (PyRun_InteractiveLoop) so that individual statements/expressions are immediately evaluated and results of expressions are printed. It also hooks GDB's readline wrappers (command_line_input) to Python so that line editing and history editing works. Additionally, Python's standard readline module is stubbed out because it conflicts with GDB's use of readline.
>
> This patch depends on a patch to handle SIGINT that I previously submitted (http://sourceware.org/bugzilla/show_bug.cgi?id=13265) to handle SIGINT in the interactive loop.
>
> Thanks!
There already is an established behaviour for python without arguments
(with or without a terminal).
(gdb) python
> print 1 + 2
> end
3
(gdb)
I've read the thread and I don't seen anyone raising this issue (could
have missed it though. I saw Tom's message re: what output CLI will
generate, but this is about behaviour).
I've read the patch and I don't think using from_tty is ok to select
between the different behaviours.
Can we pick a different way of invoking the python interpreter?