From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 843 invoked by alias); 30 Jan 2012 17:19:07 -0000 Received: (qmail 833 invoked by uid 22791); 30 Jan 2012 17:19:06 -0000 X-SWARE-Spam-Status: No, hits=-3.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-vx0-f169.google.com (HELO mail-vx0-f169.google.com) (209.85.220.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 Jan 2012 17:18:53 +0000 Received: by vcbfl11 with SMTP id fl11so3408777vcb.0 for ; Mon, 30 Jan 2012 09:18:53 -0800 (PST) Received: by 10.220.107.79 with SMTP id a15mr9838562vcp.61.1327943932952; Mon, 30 Jan 2012 09:18:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.220.107.79 with SMTP id a15mr9838546vcp.61.1327943932865; Mon, 30 Jan 2012 09:18:52 -0800 (PST) Received: by 10.220.204.195 with HTTP; Mon, 30 Jan 2012 09:18:52 -0800 (PST) In-Reply-To: References: <09787EF419216C41A903FD14EE5506DD030F1EB39B@AUSX7MCPC103.AMER.DELL.COM> <09787EF419216C41A903FD14EE5506DD030F1EB45D@AUSX7MCPC103.AMER.DELL.COM> Date: Mon, 30 Jan 2012 17:25:00 -0000 Message-ID: Subject: Re: Make the "python" command resemble the standard Python interpreter From: Doug Evans To: Khoo Yit Phang Cc: Tom Tromey , Paul_Koning@dell.com, gdb-patches@sourceware.org X-System-Of-Record: true Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00996.txt.bz2 On Sun, Jan 29, 2012 at 7:10 PM, Khoo Yit Phang wrote: > Hi, > > On Jan 26, 2012, at 12:43 PM, Doug Evans wrote: > >> On Tue, Jan 24, 2012 at 9:30 AM, Tom Tromey wrote: >>>>>>>> "Doug" =3D=3D Doug Evans writes: >>> >>> Doug> I'm not that comfortable with having the python command having su= ch >>> Doug> varying behaviours (especially based on the value of from_tty). >>> >>> What bad effect do you think it will cause? >> >> [for example] >> Suppose I want to cut-n-paste some lines from a script into my session? >> Maybe as a quick hack or maybe to test something out or whatever. >> >> With this change I can't do that for something that contains: >> >> python >> foo >> end > > This scenario works perfectly fine in my current implementation based on = from_tty: "python\n" starts the Python REPL, "foo\n" runs in the interprete= r, and "end\n" quits the interpreter ("end" by itself in a line is speciall= y recognized as an alternative to Ctrl-D), which has the same outcome as in= the script. Assuming the script didn't intentionally force some keyboard interaction. [In emacs I sometimes just cut-n-paste a part of a script en masse.] Plus, with some playing around I found this: --- foo.gdb - snip --- python if 0 =3D=3D 1: print "foo" print "bar" end --- snip --- (gdb) source foo.gdb bar (gdb) But cut-n-paste that script into gdb and I get this: (gdb) python if 0 =3D=3D 1: print "foo" print "bar" end >>> ... ... File "", line 3 print "bar" ^ SyntaxError: invalid syntax >>> (gdb) [For reference sake, here's how I cut-n-pasted it in emacs: C-x C-f foo.gdb RET C-space C-x ] C-b M-w C-x b RET C-y RET I hope I transcribed that right.] Python's repl expects a blank line to end the block. I don't know if there's a way to work around this. Maybe there is. So now I'm even less comfortable.