From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5957 invoked by alias); 13 Jan 2012 21:37:54 -0000 Received: (qmail 5949 invoked by uid 22791); 13 Jan 2012 21:37:53 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from router-304.cs.umd.edu (HELO bacon.cs.umd.edu) (128.8.127.145) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 13 Jan 2012 21:37:40 +0000 Received: from wireless-206-196-163-53.umd.edu (wireless-206-196-163-53.umd.edu [206.196.163.53]) (Authenticated sender: khooyp) by bacon.cs.umd.edu (Postfix) with ESMTPSA id 72166B40939; Fri, 13 Jan 2012 16:37:38 -0500 (EST) Subject: Re: Make the "python" command resemble the standard Python interpreter Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Khoo Yit Phang In-Reply-To: Date: Fri, 13 Jan 2012 21:39:00 -0000 Cc: Khoo Yit Phang Content-Transfer-Encoding: quoted-printable Message-Id: <34554F70-593C-4128-B2F2-23437C948462@cs.umd.edu> References: To: gdb-patches@sourceware.org X-CSD-MailScanner-ID: 72166B40939.A6AE1 X-CSD-MailScanner: Found to be clean X-CSD-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-50, required 5, autolearn=not spam, ALL_TRUSTED -50.00) X-CSD-MailScanner-From: khooyp@cs.umd.edu X-CSD-MailScanner-Watermark: 1327095458.75834@SZAHQI8sChoIqjVLd8NcpA 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/msg00505.txt.bz2 (Sorry if you received a duplicate email, my previous reply was rejected by= gdb-patches.) Hi, On Jan 13, 2012, at 8:56 AM, Phil Muldoon wrote: > Tom Tromey writes: >=20 >>>>>>> "Yit" =3D=3D Khoo Yit Phang writes: >>=20 >> Yit> + TRY_CATCH (except, RETURN_MASK_ALL) >> Yit> + { >> Yit> + struct cleanup *cleanup =3D gdbpy_suspend_sigint_handler (); >> Yit> + p =3D command_line_input (prompt, 0, "python"); >> Yit> + do_cleanups (cleanup); >> Yit> + } >> Yit> + >> Yit> + /* Detect Ctrl-C and treat as KeyboardInterrupt. */ >> Yit> + if (except.reason =3D=3D RETURN_QUIT) >> Yit> + return NULL; >>=20 >> 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. >=20 > 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. Tom's email did not include all the code: the other cases are handled via g= dbpy_convert_exception. > Also, the cleanup in the TRY_CATCH seems weird? Can you clarify? In this case, gdbpy_suspend_sigint_handler suspends Python's interrupt hand= ler and reverts to GDB's. The cleanup handler resumes Python's interrupt ha= ndler, and additionally captures any changes to GDB's signal handler, and s= o has to be run before returning to Python. >> Yit> + d =3D PyModule_GetDict (m); >>=20 >> Do we need error checking? >> I didn't look at the API docs. >=20 > 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. Sounds reasonable. Yit January 13, 2012