From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12216 invoked by alias); 12 Jan 2012 16:40:46 -0000 Received: (qmail 11934 invoked by uid 22791); 12 Jan 2012 16:40:42 -0000 X-SWARE-Spam-Status: No, hits=-3.2 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; Thu, 12 Jan 2012 16:40:29 +0000 Received: by vcge1 with SMTP id e1so1763228vcg.0 for ; Thu, 12 Jan 2012 08:40:28 -0800 (PST) Received: by 10.52.35.69 with SMTP id f5mr2160555vdj.29.1326386427385; Thu, 12 Jan 2012 08:40:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.52.35.69 with SMTP id f5mr2160545vdj.29.1326386427322; Thu, 12 Jan 2012 08:40:27 -0800 (PST) Received: by 10.220.229.1 with HTTP; Thu, 12 Jan 2012 08:40:27 -0800 (PST) In-Reply-To: References: Date: Thu, 12 Jan 2012 16:48:00 -0000 Message-ID: Subject: Re: Make the "python" command resemble the standard Python interpreter From: Doug Evans To: Khoo Yit Phang Cc: 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/msg00407.txt.bz2 On Tue, Jan 10, 2012 at 4:18 PM, Khoo Yit Phang 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 l= oop (PyRun_InteractiveLoop) so that individual statements/expressions are i= mmediately 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 submitte= d (http://sourceware.org/bugzilla/show_bug.cgi?id=3D13265) 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?