RE: Make the "python" command resemble the standard Python interpreter

Paul_Koning
2012-01-12T16:52:21Z

>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?

But "python" seems rather an intuitive way of doing it. The existing behavior is quite surprising and unintuitive, because it accumulates an entire multi-line string without any parsing, and then hands it off all at once to Python. I see no reason to preserve that behavior if we have a normal Python interactive interpreter loop. That loop does everything the existing thing does and far more/better, so it should replace the old behavior.

For example, if you commit a syntax error, the existing machinery doesn't tell you until much later, when you say "end". The interactive interpreter will tell you at the time you make the error.

paul