From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10032 invoked by alias); 13 Jan 2012 13:56:52 -0000 Received: (qmail 10017 invoked by uid 22791); 13 Jan 2012 13:56:51 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 13 Jan 2012 13:56:17 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0DDuFU1016026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 13 Jan 2012 08:56:15 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0DDuEW8001222; Fri, 13 Jan 2012 08:56:14 -0500 From: Phil Muldoon To: Tom Tromey Cc: Khoo Yit Phang , gdb-patches@sourceware.org Subject: Re: Make the "python" command resemble the standard Python interpreter References: Reply-to: pmuldoon@redhat.com X-URL: http://www.redhat.com Date: Fri, 13 Jan 2012 14:09:00 -0000 In-Reply-To: (Tom Tromey's message of "Wed, 11 Jan 2012 13:51:35 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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/msg00476.txt.bz2 Tom Tromey writes: >>>>>> "Yit" == Khoo Yit Phang writes: > I think it would be better to make it not conflict somehow. > > Yit> + TRY_CATCH (except, RETURN_MASK_ALL) > Yit> + { > Yit> + struct cleanup *cleanup = gdbpy_suspend_sigint_handler (); > Yit> + p = command_line_input (prompt, 0, "python"); > Yit> + do_cleanups (cleanup); > Yit> + } > Yit> + > Yit> + /* Detect Ctrl-C and treat as KeyboardInterrupt. */ > Yit> + if (except.reason == RETURN_QUIT) > Yit> + return NULL; > > Does this case need the Python exception to be set? If not, I think it > would be good to expand this comment to explain the situation. Yes, I think it does. If command_line_input fails for a reason other than the one case of Ctrl-C, the exception I believe with be eaten. Also, the cleanup in the TRY_CATCH seems weird? > Yit> + m = PyImport_AddModule ("__main__"); > Yit> + if (m == NULL) > Yit> + error (_("Error while executing Python code.")); > > You have to do something with the Python exception here. > Usually we use gdbpy_print_stack, but sometimes other things are > appropriate. > Yit> + d = PyModule_GetDict (m); > > Do we need error checking? > I didn't look at the API docs. Nope, PyModule_GetDict never fails. But given how things change in Python (ie 3.x vs 2.x) it might be cautious just to add a check here anyway. Cheers, Phil